SlideShare a Scribd company logo
INTRODUCTION TO THE TEMPLATE HIERARCHY
         Al Davis- WordCamp Toronto Developers
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
Question?



What file does WordPress use to display a specific type of
content?
Answer:
But first the basics
               header.php




                               sidebar.php




                                  The Loop




                  footer.php
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
So what’s with all these files in a theme then?
Welcome to the Template Hierarchy




How does it all work?
Home page example


If a visitor goes to your home page at

www.example.com/yourblog



WordPress does the following:
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
It’s a Rule!!


When no other template files exist, WordPress will always
display index.php



                Always
Category page example


User clicks on your link for a category page at:

www.example.com/yourblog/category/cats-are-dumb

What happens?
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
Lather , rinse , repeat



WordPress follows this logic for all content types with just minor
changes
Single Post


1.Single-{post-type}.php. If the post type was cars, it would look
  for single-cars.php

2.single.php

3.index.php
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
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
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
Questions?
Ad

More Related Content

What's hot (20)

Custom Menu Support for WordPress Themes
Custom Menu Support for WordPress ThemesCustom Menu Support for WordPress Themes
Custom Menu Support for WordPress Themes
DaisyOlsen
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
topher1kenobe
 
Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015
topher1kenobe
 
GDI WordPress 4 January 2012
GDI WordPress 4 January 2012GDI WordPress 4 January 2012
GDI WordPress 4 January 2012
pamselle
 
Approaches To WordPress Theme Development
Approaches To WordPress Theme DevelopmentApproaches To WordPress Theme Development
Approaches To WordPress Theme Development
Catch Themes
 
Blog backup & recovery
Blog backup & recoveryBlog backup & recovery
Blog backup & recovery
HotBlogTips.com
 
<?php + WordPress
<?php + WordPress<?php + WordPress
<?php + WordPress
Christopher Reding
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
mdawaffe
 
WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1
David Bisset
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & Security
Michelle Davies (Hryvnak)
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPress
Mario Peshev
 
GDI WordPress 4 January 2012 (white)
GDI WordPress 4 January 2012 (white)GDI WordPress 4 January 2012 (white)
GDI WordPress 4 January 2012 (white)
pamselle
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
Joe Casabona
 
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Jonny Allbut
 
A Beginner’s Guide to Wordpress - WordCamp Toronto 2011
A Beginner’s Guide to Wordpress - WordCamp Toronto 2011A Beginner’s Guide to Wordpress - WordCamp Toronto 2011
A Beginner’s Guide to Wordpress - WordCamp Toronto 2011
Kathryn Presner
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
openchamp
 
WordPress Theme Reviewers Team
WordPress Theme Reviewers TeamWordPress Theme Reviewers Team
WordPress Theme Reviewers Team
Mario Peshev
 
A Beginner's Guide to WordPress - WordCamp Montreal 2012
A Beginner's Guide to WordPress - WordCamp Montreal 2012A Beginner's Guide to WordPress - WordCamp Montreal 2012
A Beginner's Guide to WordPress - WordCamp Montreal 2012
Kathryn Presner
 
A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011
Kathryn Presner
 
Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.
Jacob Martella
 
Custom Menu Support for WordPress Themes
Custom Menu Support for WordPress ThemesCustom Menu Support for WordPress Themes
Custom Menu Support for WordPress Themes
DaisyOlsen
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
topher1kenobe
 
Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015Intro to Plugin Development, Miami WordCamp, 2015
Intro to Plugin Development, Miami WordCamp, 2015
topher1kenobe
 
GDI WordPress 4 January 2012
GDI WordPress 4 January 2012GDI WordPress 4 January 2012
GDI WordPress 4 January 2012
pamselle
 
Approaches To WordPress Theme Development
Approaches To WordPress Theme DevelopmentApproaches To WordPress Theme Development
Approaches To WordPress Theme Development
Catch Themes
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
mdawaffe
 
WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1
David Bisset
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & Security
Michelle Davies (Hryvnak)
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPress
Mario Peshev
 
GDI WordPress 4 January 2012 (white)
GDI WordPress 4 January 2012 (white)GDI WordPress 4 January 2012 (white)
GDI WordPress 4 January 2012 (white)
pamselle
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
Joe Casabona
 
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Jonny Allbut
 
A Beginner’s Guide to Wordpress - WordCamp Toronto 2011
A Beginner’s Guide to Wordpress - WordCamp Toronto 2011A Beginner’s Guide to Wordpress - WordCamp Toronto 2011
A Beginner’s Guide to Wordpress - WordCamp Toronto 2011
Kathryn Presner
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
openchamp
 
WordPress Theme Reviewers Team
WordPress Theme Reviewers TeamWordPress Theme Reviewers Team
WordPress Theme Reviewers Team
Mario Peshev
 
A Beginner's Guide to WordPress - WordCamp Montreal 2012
A Beginner's Guide to WordPress - WordCamp Montreal 2012A Beginner's Guide to WordPress - WordCamp Montreal 2012
A Beginner's Guide to WordPress - WordCamp Montreal 2012
Kathryn Presner
 
A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011A Beginner's Guide to Wordpress - WordCamp Montreal 2011
A Beginner's Guide to Wordpress - WordCamp Montreal 2011
Kathryn Presner
 
Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.
Jacob Martella
 

Viewers also liked (9)

Marcus Andersson
Marcus AnderssonMarcus Andersson
Marcus Andersson
Europa InterCluster
 
Lucia Seel
Lucia SeelLucia Seel
Lucia Seel
Europa InterCluster
 
Gerd Meier Zu Köcker
Gerd Meier Zu KöckerGerd Meier Zu Köcker
Gerd Meier Zu Köcker
Europa InterCluster
 
Jenny Clucas
Jenny ClucasJenny Clucas
Jenny Clucas
Europa InterCluster
 
Jessica Michelson
Jessica MichelsonJessica Michelson
Jessica Michelson
Europa InterCluster
 
Dan Licari & David Furmage
Dan Licari & David FurmageDan Licari & David Furmage
Dan Licari & David Furmage
Europa InterCluster
 
Emiliano Duch
Emiliano DuchEmiliano Duch
Emiliano Duch
Europa InterCluster
 
Ecomm 101
Ecomm 101Ecomm 101
Ecomm 101
Al Davis
 
Cluster Manager's Election
Cluster Manager's ElectionCluster Manager's Election
Cluster Manager's Election
Europa InterCluster
 
Ad

Similar to Intro to template hierarchy WCTO (20)

Learning Wordpress - the internal guide
Learning Wordpress - the internal guideLearning Wordpress - the internal guide
Learning Wordpress - the internal guide
tom altman
 
Wordpress template hierarchy
Wordpress template hierarchyWordpress template hierarchy
Wordpress template hierarchy
Stockton Group
 
WordPress Template hierarchy
WordPress Template hierarchyWordPress Template hierarchy
WordPress Template hierarchy
Jason Yingling
 
Overview on WordPress theme file structure and working functionality
Overview on WordPress theme file structure and working functionality Overview on WordPress theme file structure and working functionality
Overview on WordPress theme file structure and working functionality
Rakesh Kushwaha
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
Thad Allender
 
Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)
SARAVANAN RAMAOORTHY
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
Naeem Junejo
 
WordPress Bootcamp Part 3 - Themes
WordPress Bootcamp Part 3 - ThemesWordPress Bootcamp Part 3 - Themes
WordPress Bootcamp Part 3 - Themes
Metronet
 
Wordpress as a CMS
Wordpress as a CMSWordpress as a CMS
Wordpress as a CMS
Michael Hammel
 
Make WordPress Themes
Make WordPress ThemesMake WordPress Themes
Make WordPress Themes
Alison Foxall
 
Dissecting WordPress Themes and Page Templates, WordPress Columbus Meetup
Dissecting WordPress Themes and Page Templates, WordPress Columbus MeetupDissecting WordPress Themes and Page Templates, WordPress Columbus Meetup
Dissecting WordPress Themes and Page Templates, WordPress Columbus Meetup
Angela Meeker
 
Building a WordPress theme
Building a WordPress themeBuilding a WordPress theme
Building a WordPress theme
Josh Lee
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
LinnAlexandra
 
WordPress Themes 101 - HighEdWeb New England 2013
WordPress Themes 101 - HighEdWeb New England 2013WordPress Themes 101 - HighEdWeb New England 2013
WordPress Themes 101 - HighEdWeb New England 2013
Curtiss Grymala
 
WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013
Curtiss Grymala
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08
Jamie Oastler
 
WordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 WorkshopWordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 Workshop
Curtiss Grymala
 
Dhaka WordPress Meetup 3 - Presentation for Template hierarchy
Dhaka WordPress Meetup 3 - Presentation for Template hierarchy Dhaka WordPress Meetup 3 - Presentation for Template hierarchy
Dhaka WordPress Meetup 3 - Presentation for Template hierarchy
Md Jahidul Islam
 
WordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopWordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute Workshop
Brendan Sera-Shriar
 
Intro To WordPress Themes
Intro To WordPress ThemesIntro To WordPress Themes
Intro To WordPress Themes
damonsharp
 
Learning Wordpress - the internal guide
Learning Wordpress - the internal guideLearning Wordpress - the internal guide
Learning Wordpress - the internal guide
tom altman
 
Wordpress template hierarchy
Wordpress template hierarchyWordpress template hierarchy
Wordpress template hierarchy
Stockton Group
 
WordPress Template hierarchy
WordPress Template hierarchyWordPress Template hierarchy
WordPress Template hierarchy
Jason Yingling
 
Overview on WordPress theme file structure and working functionality
Overview on WordPress theme file structure and working functionality Overview on WordPress theme file structure and working functionality
Overview on WordPress theme file structure and working functionality
Rakesh Kushwaha
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
Thad Allender
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
Naeem Junejo
 
WordPress Bootcamp Part 3 - Themes
WordPress Bootcamp Part 3 - ThemesWordPress Bootcamp Part 3 - Themes
WordPress Bootcamp Part 3 - Themes
Metronet
 
Make WordPress Themes
Make WordPress ThemesMake WordPress Themes
Make WordPress Themes
Alison Foxall
 
Dissecting WordPress Themes and Page Templates, WordPress Columbus Meetup
Dissecting WordPress Themes and Page Templates, WordPress Columbus MeetupDissecting WordPress Themes and Page Templates, WordPress Columbus Meetup
Dissecting WordPress Themes and Page Templates, WordPress Columbus Meetup
Angela Meeker
 
Building a WordPress theme
Building a WordPress themeBuilding a WordPress theme
Building a WordPress theme
Josh Lee
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
LinnAlexandra
 
WordPress Themes 101 - HighEdWeb New England 2013
WordPress Themes 101 - HighEdWeb New England 2013WordPress Themes 101 - HighEdWeb New England 2013
WordPress Themes 101 - HighEdWeb New England 2013
Curtiss Grymala
 
WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013
Curtiss Grymala
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08
Jamie Oastler
 
WordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 WorkshopWordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 Workshop
Curtiss Grymala
 
Dhaka WordPress Meetup 3 - Presentation for Template hierarchy
Dhaka WordPress Meetup 3 - Presentation for Template hierarchy Dhaka WordPress Meetup 3 - Presentation for Template hierarchy
Dhaka WordPress Meetup 3 - Presentation for Template hierarchy
Md Jahidul Islam
 
WordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopWordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute Workshop
Brendan Sera-Shriar
 
Intro To WordPress Themes
Intro To WordPress ThemesIntro To WordPress Themes
Intro To WordPress Themes
damonsharp
 
Ad

More from Al Davis (17)

Word camp Toronto 2017
Word camp Toronto 2017Word camp Toronto 2017
Word camp Toronto 2017
Al Davis
 
Montreal word camp 2017
Montreal word camp 2017Montreal word camp 2017
Montreal word camp 2017
Al Davis
 
Wcto2014
Wcto2014Wcto2014
Wcto2014
Al Davis
 
Wc boston
Wc bostonWc boston
Wc boston
Al Davis
 
New user guide
New user guideNew user guide
New user guide
Al Davis
 
Managing Multiple Authors with WordPress
Managing Multiple Authors with WordPressManaging Multiple Authors with WordPress
Managing Multiple Authors with WordPress
Al Davis
 
After the install
After the installAfter the install
After the install
Al Davis
 
Wcto2012- after the install
Wcto2012- after the install Wcto2012- after the install
Wcto2012- after the install
Al Davis
 
Template hierarchy -WordCamp Columbus
Template hierarchy -WordCamp ColumbusTemplate hierarchy -WordCamp Columbus
Template hierarchy -WordCamp Columbus
Al Davis
 
WordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPressWordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPress
Al Davis
 
10 things to do after the install- WordCamp Victoria 2012
10 things to do after the install- WordCamp Victoria 201210 things to do after the install- WordCamp Victoria 2012
10 things to do after the install- WordCamp Victoria 2012
Al Davis
 
Sharedhosting and WordPress
Sharedhosting and WordPressSharedhosting and WordPress
Sharedhosting and WordPress
Al Davis
 
Shared Hosting and WordPress
Shared Hosting and WordPressShared Hosting and WordPress
Shared Hosting and WordPress
Al Davis
 
Why use wordpress- ACP
Why use wordpress- ACPWhy use wordpress- ACP
Why use wordpress- ACP
Al Davis
 
Onlinehub chicago- ACP
Onlinehub  chicago- ACPOnlinehub  chicago- ACP
Onlinehub chicago- ACP
Al Davis
 
Wordpress beyond the blog
Wordpress  beyond the blogWordpress  beyond the blog
Wordpress beyond the blog
Al Davis
 
Hosting provider
Hosting providerHosting provider
Hosting provider
Al Davis
 
Word camp Toronto 2017
Word camp Toronto 2017Word camp Toronto 2017
Word camp Toronto 2017
Al Davis
 
Montreal word camp 2017
Montreal word camp 2017Montreal word camp 2017
Montreal word camp 2017
Al Davis
 
New user guide
New user guideNew user guide
New user guide
Al Davis
 
Managing Multiple Authors with WordPress
Managing Multiple Authors with WordPressManaging Multiple Authors with WordPress
Managing Multiple Authors with WordPress
Al Davis
 
After the install
After the installAfter the install
After the install
Al Davis
 
Wcto2012- after the install
Wcto2012- after the install Wcto2012- after the install
Wcto2012- after the install
Al Davis
 
Template hierarchy -WordCamp Columbus
Template hierarchy -WordCamp ColumbusTemplate hierarchy -WordCamp Columbus
Template hierarchy -WordCamp Columbus
Al Davis
 
WordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPressWordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPress
Al Davis
 
10 things to do after the install- WordCamp Victoria 2012
10 things to do after the install- WordCamp Victoria 201210 things to do after the install- WordCamp Victoria 2012
10 things to do after the install- WordCamp Victoria 2012
Al Davis
 
Sharedhosting and WordPress
Sharedhosting and WordPressSharedhosting and WordPress
Sharedhosting and WordPress
Al Davis
 
Shared Hosting and WordPress
Shared Hosting and WordPressShared Hosting and WordPress
Shared Hosting and WordPress
Al Davis
 
Why use wordpress- ACP
Why use wordpress- ACPWhy use wordpress- ACP
Why use wordpress- ACP
Al Davis
 
Onlinehub chicago- ACP
Onlinehub  chicago- ACPOnlinehub  chicago- ACP
Onlinehub chicago- ACP
Al Davis
 
Wordpress beyond the blog
Wordpress  beyond the blogWordpress  beyond the blog
Wordpress beyond the blog
Al Davis
 
Hosting provider
Hosting providerHosting provider
Hosting provider
Al Davis
 

Intro to template hierarchy WCTO

  • 1. INTRODUCTION TO THE TEMPLATE HIERARCHY Al Davis- WordCamp Toronto Developers
  • 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
  • 3. Question? What file does WordPress use to display a specific type of content?
  • 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
  • 7. So what’s with all these files in a theme then?
  • 8. Welcome to the Template Hierarchy How does it all work?
  • 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
  • 15. Single Post 1.Single-{post-type}.php. If the post type was cars, it would look for single-cars.php 2.single.php 3.index.php
  • 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

Editor's Notes

  翻译: