In this part of the series we’re going to create the templates used for pages and posts. The page template is very simple because it only has the basic structure of our design. The post template has more details, which makes it more complex. In order to complete the post page, we’re also going to do the comments template.

Introduction

We start this part of the series with our theme partially done. We have already created the design, started with the CSS and coded most of our home page. Now we’re going to code the templates for pages and single posts. We want both templates to look like our home page, so it’s the same structure we’ve already seen.

At the end of this post you can find the previous parts of the series and catch up with the development.

Pages

If you create a page and check it with our current page template, this is what you’re going to see:

Single page before corrections

We’re going to fix this by updating the page template. As we used the Default theme to build our theme, we’re just going to update the PHP file. Most of the needed CSS is already defined. The images aren’t styled yet, but we’re going to do it later, for the single posts template.

Right after the functions wp_link_pages() and the_tags() we have the post metadata. Move it outside the <div class=”entry”>, after the </div> that closes the entry content DIV. Also remove the class from the metadata paragraph because we already used this class in the home page.

Before we call the get_footer() function, add the sidebar and a clear with the following code:

With the last changes we have also finished our single post page. Here is the result:

Single post

Conclusion

With this post we have finished the main templates of our theme. Very simple changes, similar to what we’ve done for our home page. The theme is almost 100% functional. There are some missing templates, like links.php, archive.php and archives.php, that are easily updated doing the similar changes as we’ve done for the page.php file. For this reason, I’m not going to show these templates here. It’s just a repetition of what we’ve done.

Download our theme with the changes we made in this post here (76 Kb).

Next week I plan to finish these series about the WordPress theme creation. We’ll see the footer, some additional styling and the widgets I use. Thanks for the visit and don’t forget to come back for the last part.