Creating a custom page template in WordPress

While designing your WordPress site, you may want to create a page that’s different from your other pages and posts. I’ve created many websites which have a custom home page, portfolio section, site map etc… WordPress allows you to create custom templates in a few simple steps:

  1. Open up your page.php or index.php and add the following code at the very top of your page:
    Template Name: Name of your Template
  2. Save your your file as new-template-name.php (you may want to use portfolio.php, sitemap.php, etc..)
  3. Upload your file in your themes directory
  4. In your WordPress admin, edit the page that you want custom and select the newly created template from your “Template” drop down which is found under “Attributes”

That’s all it takes to create the template, but now you will need to customize it to make it look different from your other pages. You may want to have a different background, dimension, etc…

Examples of Custom Pages


If you take a look at the site map on Out of Chaos‘s website, you will find a list of all of the pages. This page could have be created simply by inserting an unordered list in the editor, but if we do it that way, then we’ll need to update it every time a new page is added or deleted. An easier way to generate the list is to use a custom template.

The site map template was created by using the following code:

Template Name: Sitemap Template
<?php get_header(); ?>
<div id="content">
	<div id="right">
		<h2><?php the_title(); ?></h2>
			<?php wp_list_pages('sort_column=menu_order&amp;exclude=25&amp;title_li'); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

The code above grabs the title of the sitemap page and then generates a list of all of the pages and excludes itself.

The ability to create custom templates allows you to create pretty much whatever you want with WordPress and makes it an ideal Content Management System.