1

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';

1 Answer 1

3

You mean something like this?

<?php
require 'path/to/wordpress/wp-blog-header.php';
bloginfo('url');
?>
3
  • 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, 2011 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.
    – Roman
    May 14, 2011 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, 2011 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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