Use WordPress core as PHP framework

For a task I required using headless WordPress, just the core without a template. Using as a PHP framework. More info about integration is available at

Power tip:
To avoid plugins redirecting after requiring wp-blog-header.php define DOING_CRON const or might be DOING_AJAX or WP_ADMIN. Gist snippet. You could also check defined constants. To avoid redirect you also might redefine wp_redirect() function.



define('DOING_CRON', true);
require dirname(__FILE__).'/wp-blog-header.php';

// Your code goes here...

Author: Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at Co-founded Blog at

2 thoughts on “Use WordPress core as PHP framework”

  1. Not sure what you are doing, but don’t forget to take a look and see if the REST API is a good fit for your project. Strong decoupling from PHP makes for an awesome development experience while retaining the strong management and plugability of WordPress.

    1. Thanks Dennis 😉 The REST API is looking great. I did an import of products from XML into WooCommerce. WC has also API, maybe I try that next time if I don’t forget.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s