Lately I’ve been covering some topics on customizing your WordPress theme. Most of this is based off the Twenty Ten theme which I like. The last topic was about creating custom child themes. In this part I want to cover creating a simple page template. There are many reasons why you might want to do this. For instance, perhaps you want your home page to look different than some of your other pages. Maybe you want a landing page, a product page, or some other layout that a page template may not include. Here we will cover adding your own templates in WordPress.
We begin by finding our page template in our theme. You can do this by going within WordPress dashboard to Appearance > Editor. If you setup a child theme then you will want to go to the core theme and grab the file there. In most cases this is named page.php. It might even be titled Page Template in the navigation bar of your website. Copy the code and paste it into your favorite text editor. Now save the file titled something different than page.php. I like to call it by the name of page that will use the new template (e.g. front-page.php).
Now before you upload it you will want to add a little bit of code so that you can find it when you plan to use it. Really it isn’t code so don’t freakout. It is just some markup that notifies WordPress that it is template and registers it. Below is what it should look like in the main area. You can just leave the rest of the code the same.
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
<-- The rest of the code from your page.php file goes here. Right now all we are editing is the template header part. Now you have your own page template. You can then go through the code and change it up as you see fit. We aren’t actually doing a new full template. We are just duplicating an old one with a new one so we can customize it later. Now that you created the template you can add new features to your code. In the right hand corner of the WordPress editor you will find the drop down on the right. Choose the template that you want and when you publish your page it will use your new template.
If you want to read more about this you can learn about it from the WordPress Codex.
Thoughts or comments? Need help? We would love to hear form you!