Execute External WordPress Functions
To execute WordPress functions in an external directory (i.e., outside of the WordPress install directory), it is necessary to include a call to wp-blog-header.php
at the top of the external file.
For example, if your WordPress-powered blog is located in a subdirectory called “blog” and the external file is in the domain root (e.g., the external file is located directly in http://domain.com/
), add the following code to the top of the external file:
<?php require_once("./blog/wp-blog-header.php"); ?>
Alternately, you can do this:
<?php require(dirname(__FILE__) .'/blog/wp-blog-header.php'); ?>
![](https://secure.gravatar.com/avatar/1de0c2609e13647bd516431e3c79da7c?s=200&d=https%3A%2F%2Fperishablepress.com%2Fwp%2Fwp-content%2Fthemes%2Fyes%2Fimg%2Favatar.png&r=pg)
About the Author
Jeff Starr = Web Developer. Book Author. Secretly Important.