Create Blank Page for Wordpress Blog Using Your Theme Template
Posted: July 8th, 2009 | Author: jriggs | Filed under: php, wordpress | 5 Comments »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 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. 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:
<?php
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
get_header();
get_sidebar();
?>
<p>Hello!</p>
<?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.
Related posts:
- Detect Adblock Users on a Wordpress Blog
- Block Spammers by IP address in Wordpress
- My Google Page Rank is Increasing!
- Blank html template – Transitional dtd
- php: Send xml/soap to Secured Server
Hi Joe,
Thanks very much for making this clear!
Just found it on the WP forum.
Followed all of your steps, did even create the /blank page that’s a good start-off (for later html).
Then realised, I was lost in first instance (no idea how to attach this page as template).
Then found this explanation, you might consider to add to above explanation?
http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
Thanks again.
Ok now I’m really confused. I thought the whole point of WP was to enable somebody to easily create pages that are easily editable …?
I did try to create an easily editable page using “Add Page” but as you said, it included a ton of code from my home page.
I must be missing something …
This post is well thought-out and informative.I’m interested,must give a try.
thanks… needed this
I found your post while searching for help in creating a blank page on my blog so that I can easily upload an Amazon aStore. The current settings of my theme prevent the aStore from fully showing up whether I use the inline frame or frameset codes. But unfortunately, I am clueless about even the first step you mention — set up a new file in my blog’s root directory. I have no idea how to do that or even where the root directory is. I’d appreciate your help with this.
Thanks very much.