Super Plugin Sale! Your Choice: BOGO or 30% Off »
Web Dev + WordPress + Security

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

About the Author
Jeff Starr = Web Developer. Book Author. Secretly Important.
Blackhole Pro: Trap bad bots in a virtual black hole.
Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
.htaccess made easy: Improve site performance and security.
Thoughts
All free plugins updated and ready for WP 6.6 dropping next week. Pro plugin updates in the works also complete :)
99% of video thumbnail/previews are pure cringe. Goofy faces = Clickbait.
RIP ICQ
Crazy that we’re almost halfway thru 2024.
I live right next door to the absolute loudest car in town. And the owner loves to drive it.
8G Firewall now out of beta testing, ready for use on production sites.
It's all about that ad revenue baby.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.