This document discusses WordPress's template hierarchy. It explains that WordPress uses different template files to display different types of content. For example, it will use home.php for the homepage if it exists, or index.php by default. For category pages, it will try category-slug.php, category-id.php, category.php, archive.php, and finally index.php. This logic is followed for other content types like single posts, pages, author pages, and more. The document provides examples of the template file names WordPress looks for in different situations.
2. Who’s the Bald Guy?
Co-Organizer
TorontoWordPress and WordPress Developer Meetup groups
Toronto WordCamp ( end users) and Toronto WordCamp Developers
Presenter at Numerous WordCamps this year in both Canada and the USA
Program Manager - Hostopia- WordPress Manager for world’s largest hosting wholesale provider
Instructor- George Brown College
Intro to WordPress
Intro to WordPress Theme and Plugin Development
5. But first the basics
header.php
sidebar.php
The Loop
footer.php
6. The requirements
To build a functioning WordPress theme you need the following
files:
index.php
style.css
Your site will suck, but it will be functioning
9. Home page example
If a visitor goes to your home page at
www.example.com/yourblog
WordPress does the following:
10. Home page example
1.Determines if you have a static front page assigned.If so, it loads
it.
2.If there is no static front page, it looks for a file called home.php
3.If there is no home.php file, it then defaults to index.php
11. It’s a Rule!!
When no other template files exist, WordPress will always
display index.php
Always
12. Category page example
User clicks on your link for a category page at:
www.example.com/yourblog/category/cats-are-dumb
What happens?
13. Category page example
Wordpress looks for the following:
1. category-{slug}.php - in this example it would be category-cats-are-dumb.php
2. category-{id}.php if the category id is 4, then it would be category-4.php
3. category.php
4. archive.php
5. index.php
14. Lather , rinse , repeat
WordPress follows this logic for all content types with just minor
changes
16. Page Display
1.Custom template file- the page template assigned to the page
( example : alsawesometemplatefile.php)
2.page-{slug}.php . If the slug is cats-suck then it would be page-
cats-suck.php
3.page-{id}.php
4.page.php
5.index.php
17. Author Display (last example)
1.Author-{nicename}.php If the author was dallas (my dog), the file
would be author-dallas.php
2.author-{id}.php
3.Author.php
4.Archive.php
5.Index.php
18. The forgotten templates....
1. Tag Display
2. 404 Display
3. Custom Taxonomies Display
4. Custom Post Types Display
5. Date Display
6. Search Result Display
7. Attachment Display