I came across an issue the other day where I needed to include a dynamic WordPress menu on a static page outside of the WordPress installation – my menu was included within WordPress as a dynamic sidebar holding a widget.
I thought this may prove to be a difficult task, but I hadn’t realised that the team at WordPress had already come up with a solution for this.
Include a WordPress function outside of WordPress
To include a WordPress function outside of WordPress, all you need to do is include wp-load.php at the start of your static page – this loads in all WordPress functions etc, ready for your use.
So try using the following code at the very top of your static page:
<?php require( '../your_wordpress_folder/wp-load.php' ); ?>
Change your_wordpress_folder to the root folder of your WordPress installation; I have found a good way to include a file without using an immense amount of dots and slashes is to write your includes like this:
<?php require( $_SERVER['DOCUMENT_ROOT'].'/your_wordpress_folder/wp-load.php' ); ?>
This will tell the include path to start from the root folder of your domain, I find myself using this method more and more.
After putting this code at the top of your static page, you will find that you can call most WordPress functions as normal, such as – get_header(), get_footer(), get_dynamic_sidebar(), etc. It really is as simple as that!
Let me know of any other great tips you have discovered whilst using WordPress for your web design, it’d be great to get a collection on the go.


Hi James,
Excellent – It works a treat : ) Real point…click…GO! Just what I needed. THANKS!
Now…
I guess a person could just run the static site as is…with a few functions here and there, where applicable. This is what I intend to do since I don’t plan on having a huge site of a million pages.
The only thing that thros me a bit is some sort of directory structure since I wouldn’t want to run all .html pages in one messy root folder.
Any similar easy means to restructure, if I wanted to do that?
Can also run a seperate blog, as such, based on the same template I assume?