Create Blank Page for WordPress Blog Using Your Theme Template

There may come a time when you need to create a blank page on your WordPress site that still uses your template’s header, footer and sidebar.  For example, if you incorporate your own custom search from google, you will need to specify a landing page where the search results will be displayed.

You could use WordPress to create a new page, but this has some problems.wordpress logo

  • WordPress tends to add code to the page the you don’t need or want
  • You will need to recreate this file whenever you switch themes or upgrade.
  • You cannot easily control where this file is created.

To avoid these problems we can use some built-in functions to display a blank page that uses your template and gives you greater control of the page’s content.

First, create a new file in the root directory of your blog (the directory that contains ‘wp-blog-header.php’).  Name it whatever makes sense to you but make sure to give it the ‘.php’ extension.  Copy the following into the file you have just created:

Hello!

;
 
<!--?php 
get_footer();
?-->

You can see an example of this page here – http://joe-riggs.com/blog/blank.php.  You can add any valid html or javascript to the section between the php tags and will be displayed.  If you don’t want to display the header, sidebar or footer you can simply comment out or remove that particular line – ie : delete entire  “get_sidebar();” line to remove the sidebar.