Custom Page Templates
Custom pages can be created in a few ways. In the most specific instance they can be named within the file by adding <?php /* Template Name: yourpagename */ ?> to the top of the file. What you name the file doesn't matter. It could be pagesquirrel.php, pagex.php, etc.
WordPress will look for the name in the file and add it to the templates you may choose from when editing pages. You will then simply select the template from a drop down list. This is the method used for creating this page.
Pages can also be identified by their file names. If you name your file by the page slug or id using page-slug.php or page-id.php WordPress will use that file. The page we are on has a slug "hierarchy" and is page number 10. Thus if using that method we could have named our file either page-hierarchy.php or page-10.php.
The code used in this page
This page's template file is named page-9.php which is the id of the parent of this page. Knowing that it would be used for multiple pages in this section, I chose to add a name of page-templatehierarchy within the file, so that I could apply it pages as needed.
<?php /* Template Name: page-templatehierarchy */ ?>
<!-- Header -->
<?php include (TEMPLATEPATH . '/header.php'); ?>
<!-- End Header -->
<!-- middle content area -->
<div id="midbox">
<!-- sidebar -->
<?php include (TEMPLATEPATH . '/sidebarhierarchy.php'); ?>
<!-- end sidebar -->
<!-- main content area -->
<div id="main">
<!-- WordPress Loop -->
<div class="blogpostwrapper">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="blogpost">
<h3 class="entrytitle" id="post-<?php the_ID(); ?>"> <a
href="<?php the_permalink() ?>" rel="bookmark"><?php
the_title(); ?> </a> </h3>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php else : ?>
<h6 class="center">Not Found</h6>
<p class="center">Sorry, but you are looking for something
that isn't here.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
</div>
<!-- End WordPress Loop -->
</div>
<!-- end main content area -->
</div>
<!-- end middle content area -->
<!-- Footer -->
<?php include (TEMPLATEPATH . '/footer.php'); ?>
<!-- Footer -->
