This tutorial will show you the very basics of how to create custom page templates. Page templates are a great way to create custom layouts for individual pages on your website. There are, of course, other methods to customizing content such as using post formats, custom post types and many other ways. I personally think that custom page templates are the very easiest when learning how to use WordPress as a CMS.

When would you use a custom page template?

There are countless uses for custom page templates although some of the more common uses that I have seen are for the following pages:

  • Full Width Page
  • Left Sidebar Page
  • Right Sidebar Page
  • Archives Page (archives.php)
  • Portfolio Page
  • Contact Page
  • Meet the Team Page
  • Shopping Cart Page
  • etc…

The list could go on and on. Hopefully this gives you some ideas as to the application of custom page templates. We have some tutorials coming up that will utilize custom page templates in much more depth.

To get started, this is how it works. Let’s say you want to create a custom page template for the contact page of your site. Create a file called template-contact.php (The file doesn’t have to be labeled with template-. I prefer to use the template- structure for all custom page templates so they are easier to recognize within the file structure.) and at the very beginning of the file insert the following code:

001	<?php
002	/*
003	Template Name: Contact Page
004	*/
005	?>
007	<h2>Page title...</h2>
008	<p>The site content... etc</p>
009	<p>...</p>

Once you have input the given code you can go ahead and create your page however you would like. As far as the basics are concerned, that is all you have to do. Go ahead and save the file and go into the backend to your pages tab. On the right side you will see a new page template with the title that you defined.

Here is an example of what the page templates will look like:

If you have any questions how to use custom page templates in other methods please comment and let me know so I can add to this.