WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I just have a dumb .php file sitting on my WP server and I wanted it to access WP info through the API, how would I go about doing that? For example if I wanted to call


As I have scored myself a downvote (with no explanation) I will expound upon why I am interested in this. Sure I can access WP API from all the built-in pages. But let's say I have a page that has little to do with WP. Seems like a lot of overhead to create say a custom template page and then hook it into an actual post, all so that I can have access to a few WP API calls.

I ended up using something like this:

require $_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php';
share|improve this question
up vote 2 down vote accepted

You mean something like this?

require 'path/to/wordpress/wp-blog-header.php';
share|improve this answer
I've always used wp-load.php and define('WP_USE_THEMES', false);, I'm curious what the differences are, if any. – Milo May 14 '11 at 6:47
The codex is using the wp-blog-header.php file. I've just looked at the two files and it seems that wp-blog-header.php also calls wp-load.php, template-loader.php and the function wp(). The wp() function then calls the main() method of the WP class which sets up all required global variables. The constant WP_USE_THEMES is by default false and only set in the index.php which is never called here, so it I think it isn't really necessary. – rofflox May 14 '11 at 10:32
Thank-you for the how-to as well as some discussion on the why. I am always more interested in that part. – mrtsherman May 14 '11 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.