Using WordPress Core externally can be quite useful when wanting to utilize WordPress functions from within another project/app. I’m setting up a cron job at server level, but I wanted to be able to leverage WordPress functionality. Because of how WP Cron works (initiated on page load, not time), I wanted to separate my cron process from the WordPress installation.
After a little digging around, I found this thread on StackExchange. It explains the setting up how to access WordPress core externally.
The following code will allow you to use all WordPress Core functionality!
{code type=php}
Test it
{code type=php}
if( function_exists( ‘update_option’ ) )
echo ‘We have WordPress support’;
else
echo ‘no WordPress support’;
{/code}
Use WordPress core externally!
Now that you have access to WordPress core functionality, the limit is the sky! (or at least the latest version of WordPress).
I’m not sure if this will get munged by any parsers, but your first code snippet doesn’t look like it’d work.
<!–?php // All that is required to bootstrap into WordPress.
require(‘../wordpress/wp-load.php’);
should be
<?php
// All that is required to bootstrap into WordPress.
require('../wordpress/wp-load.php');
Thanks for the reply, Patrick!
Looks like the typical case of Visual Editor vs. HTML – didn’t notice that, thanks!