Hack: Using WordPress Functions Without WordPress

So you want to create a utility page that accesses things on your site, but without all of the overhead of your theme, headers, etc. You can create any PHP script and simply include all of the WordPress functions to access as you wish.

Here is a bit of code that just lists all of the post titles on a plain text page. I use this to search through my years of posts without any hassle, so see when I last talked about some topic or another.


$post_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => -1));
while($post_query->have_posts()) {

I’m using post titles as an example here. You can make this a little more fancy or include more about each post. Maybe even put them in an HTML table. Or, do just about anything else.

The key here is the one line at the top. This brings in the wp-config.php script which then includes everything else. Notice that I’m assuming you are down one level from the main WordPress level, so perhaps in a test/test.php file.

Leave a Reply

Your email address will not be published. Required fields are marked *