Why I Love Feedback, or Templates and Hierarchy, Continued
I got some feedback from both ends of the spectrum – my physicist husband who was impatient of my soothing words and dangling participles, and my writer friends who glazed over at the mention of HTML. I was also delighted to hear that one reader has used my affiliate linkto buy the book! I cannot begin to tell you how valuable feedback is to me as I struggle to learn and teach simultaneously. People – don’t be shy of leaving comments. Constructive criticism is always welcome, and if I can help grow a community that discusses and shares around my posts, I will have achieved every blogger’s dream.
Continuing with Chapter 3 of our book, the really important thing to remember about template files is that they show our visitors what we want them to see at every location on the site. Imagine that you have a deck of cards, and you scatter them throughout your house so that people in the living room see the Queen of Hearts, and those in the kitchen see the Jack of Clubs. The person’s location in the house determines what card they see. Similarly, the person’s location on your site determines what they see on their screen – which you have set using the appropriate template file. In the next section we will talk about how WordPress knows what to show at every location.
The Template Hierarchy
This diagram (which you can click to see at full size on the WordPress.org site) shows us the philosophy behind WordPress’s template structure. It’s less complicated than it looks.
Remember that when we installed WordPress on the local system, we had to set up a database. That database is really the heart of WordPress – it’s just a glorified filing system! When a visitor clicks on the link to a page, WordPress sends a query to the database to ask which page it should show on the screen. Notice the simple question in the box on the extreme left: what page? That is what a WordPress theme is mostly about. The rest, as Rabbi Hillel said, is commentary – go and learn.
What Pumpkin? (Sorry, my kids are Homestuck fans)
The first line of answers consists of the specific template files that the theme could show you in response to a click – ranging from the classic 404 Not Found page through Search Results to the various kind of single pages, blog posts, archive pages etc.
- There are special templates for archiving posts by author, by date or by category.
- You can create a special front-page.php if you want to make your front page different from the rest of the site.
- If you have multiple authors, you can create author.php template files to differentiate between them – adding their Gravatar profiles, for example.
- If you are featuring different kind of products on different pages, you can create custom post types for each one.
That’s the end of Chapter 3 – if you are still with me, Chapter 4 takes us back to the WAMP installation to learn how to build our own basic theme. Stay tuned and remember that I LOVE comments, questions and constructive criticism!