Using WordPress core externally

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!

<?php // All that is required to bootstrap into WordPress.
require('../wordpress/wp-load.php');

Test it

if( function_exists( 'update_option' ) )
echo 'We have WordPress support';
else
echo 'no WordPress support';

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).

2 thoughts on “Using WordPress core externally”

  1. 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');

Leave a Reply

Your email address will not be published. Required fields are marked *