/

October 30, 2009

WP Theme Lesson #2: Template Files and Templates

Template files and Templates is the second lesson of my WordPress theme tutorial series. If you haven’t read Lesson #1, stop right now and go read lesson one. Otherwise, you will not understand the terms used in lesson two.

Now that we’ve gotten passed the rules and terminology, this lesson will get you familiar with template files, templates, and the structure of each page.

The one thing to remember is that each page of your blog is made up of multiple template files. Here’s an example of the front page.

index

In the example above, your front page is made up of four template files: header, index, sidebar, and footer.

Header Template File:
header-template
Your blog’s title and description sit in this file. They usually remain the same through out the whole blog.

Index Template File:
This one contains your post title, content (text and images of each entry), and post meta data (information about each post like: who’s the author, when you published it, under which categories, and how many comments).

index-template

Sidebar Template File:
This controls your Page links listing, category links listing, archive links listing, blogroll listing, and etcetera. (The Sidebar doesn’t need to be on the right side of the layout. The example I’m using is a typical two column blog layout.)

sidebar-template.gif

Footer Template File:
footer-template
Like the header.php template file, the footer usually doesn’t change from page to page. You can put anything in this file, but usually your copyright information.

Now let me explain why index.php is red, in the example above. Index.php is red to indicate that, that area will change, depending on which page of the blog you’re on.

If you were on a single post page, your page would consist of these four template files: header, single, sidebar, and footer.

single

Follow this WordPress Theme Tutorial Series from the beginning.