Creating templates within your theme
You've now got a functional basic template for your theme. It works great on the main blog page and successfully loads content for anything you can click on in your site.
However, we want slightly different templates for other types of content on our site. For example, a Single Post page needs to have a Comments form where visitors can post comments; the Page page doesn't need to show the date, category, or tags; and the Category page should show the category name.
Before we can create other templates, we need to break up the main index.php
file into parts so that these different templates can share the common elements. I've mentioned many times the importance of the header, sidebar, and footer. We're going to break them up now. First, let's take a quick look at how it works.
Understanding the WordPress theme
The WordPress theme is actually composed of a number of template files. This allows the different parts of the site (such as the frontend, blog archive...