Load WordPress Core In A External Script

The potential uses for the integrate the WordPress core functionality are varied. Starting with external debugging, testing own plugins or running extensive import and export processes like I used in some of my previous articles.

Change the include path of wp-load.php if your script isn’t located in the root directory of your WordPress installation!

define('WP_USE_THEMES', false);
require_once(dirname(__FILE__).'/wp-load.php');
ob_end_clean();

...your code...

Provides the ability for Admins only!

define('WP_USE_THEMES', false);
require_once(dirname(__FILE__).'/wp-load.php');
ob_end_clean();

if( !is_user_logged_in() || (is_user_logged_in() && !current_user_can('administrator')) )
{
     wp_redirect(wp_login_url(), 301);
     exit;
}

...your code...
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn