Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

 bloginfo('url');

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

1 Answer 1

up vote 2 down vote accepted

You mean something like this?

<?php
require 'path/to/wordpress/wp-blog-header.php';
bloginfo('url');
?>
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
3  
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

 
discard

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.