SlideShare une entreprise Scribd logo
1  sur  19
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?

Contenu connexe

Tendances

Custom Menu Support for WordPress Themes
Custom Menu Support for WordPress ThemesCustom Menu Support for WordPress Themes
Custom Menu Support for WordPress ThemesDaisyOlsen
 
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, 2015topher1kenobe
 
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, 2015topher1kenobe
 
GDI WordPress 4 January 2012
GDI WordPress 4 January 2012GDI WordPress 4 January 2012
GDI WordPress 4 January 2012pamselle
 
Approaches To WordPress Theme Development
Approaches To WordPress Theme DevelopmentApproaches To WordPress Theme Development
Approaches To WordPress Theme DevelopmentCatch Themes
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIsmdawaffe
 
WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1David Bisset
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityMichelle Davies (Hryvnak)
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPressMario 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 SecurityJoe 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 2012Jonny 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 2011Kathryn Presner
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themesopenchamp
 
WordPress Theme Reviewers Team
WordPress Theme Reviewers TeamWordPress Theme Reviewers Team
WordPress Theme Reviewers TeamMario 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 2012Kathryn 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 2011Kathryn 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
 

Tendances (20)

Custom Menu Support for WordPress Themes
Custom Menu Support for WordPress ThemesCustom Menu Support for WordPress Themes
Custom Menu Support for WordPress Themes
 
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
 
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
 
GDI WordPress 4 January 2012
GDI WordPress 4 January 2012GDI WordPress 4 January 2012
GDI WordPress 4 January 2012
 
Approaches To WordPress Theme Development
Approaches To WordPress Theme DevelopmentApproaches To WordPress Theme Development
Approaches To WordPress Theme Development
 
Blog backup & recovery
Blog backup & recoveryBlog backup & recovery
Blog backup & recovery
 
<?php + WordPress
<?php + WordPress<?php + WordPress
<?php + WordPress
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1
 
NEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & SecurityNEPA BlogCon 2013 - WordPress Customization & Security
NEPA BlogCon 2013 - WordPress Customization & Security
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPress
 
GDI WordPress 4 January 2012 (white)
GDI WordPress 4 January 2012 (white)GDI WordPress 4 January 2012 (white)
GDI WordPress 4 January 2012 (white)
 
WordPress Customization and Security
WordPress Customization and SecurityWordPress Customization and Security
WordPress Customization and Security
 
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
 
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
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
 
WordPress Theme Reviewers Team
WordPress Theme Reviewers TeamWordPress Theme Reviewers Team
WordPress Theme Reviewers Team
 
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
 
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
 
Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.
 

En vedette (9)

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

Similaire à Introduction to WordPress Template Hierarchy

Template hierarchy -WordCamp Columbus
Template hierarchy -WordCamp ColumbusTemplate hierarchy -WordCamp Columbus
Template hierarchy -WordCamp ColumbusAl Davis
 
Learning Wordpress - the internal guide
Learning Wordpress - the internal guideLearning Wordpress - the internal guide
Learning Wordpress - the internal guidetom altman
 
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
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme developmentThad Allender
 
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
 
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 Workshop: Part 2
WordPress Theme Workshop: Part 2WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2David Bisset
 
advance theme development
advance theme developmentadvance theme development
advance theme development1amitgupta
 
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 Toronto08Jamie Oastler
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Emma Jane Hogbin Westby
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themesDaisyOlsen
 
WordPress Template hierarchy
WordPress Template hierarchyWordPress Template hierarchy
WordPress Template hierarchyJason Yingling
 
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 WorkshopBrendan Sera-Shriar
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme developmenthenri_makembe
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themesrfair404
 
Wordpress template hierarchy
Wordpress template hierarchyWordpress template hierarchy
Wordpress template hierarchyStockton Group
 

Similaire à Introduction to WordPress Template Hierarchy (20)

Template hierarchy -WordCamp Columbus
Template hierarchy -WordCamp ColumbusTemplate hierarchy -WordCamp Columbus
Template hierarchy -WordCamp Columbus
 
Learning Wordpress - the internal guide
Learning Wordpress - the internal guideLearning Wordpress - the internal guide
Learning Wordpress - the internal guide
 
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 ...
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
 
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
 
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
 
WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2
 
advance theme development
advance theme developmentadvance theme development
advance theme development
 
WordPress Theming 101
WordPress Theming 101WordPress Theming 101
WordPress Theming 101
 
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
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
 
WordPress Template hierarchy
WordPress Template hierarchyWordPress Template hierarchy
WordPress Template hierarchy
 
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
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme development
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Drupal Front End PHP
Drupal Front End PHPDrupal Front End PHP
Drupal Front End PHP
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
 
Wordpress template hierarchy
Wordpress template hierarchyWordpress template hierarchy
Wordpress template hierarchy
 

Plus de Al Davis

Word camp Toronto 2017
Word camp Toronto 2017Word camp Toronto 2017
Word camp Toronto 2017Al Davis
 
Montreal word camp 2017
Montreal word camp 2017Montreal word camp 2017
Montreal word camp 2017Al Davis
 
New user guide
New user guideNew user guide
New user guideAl Davis
 
Managing Multiple Authors with WordPress
Managing Multiple Authors with WordPressManaging Multiple Authors with WordPress
Managing Multiple Authors with WordPressAl Davis
 
After the install
After the installAfter the install
After the installAl Davis
 
Wcto2012- after the install
Wcto2012- after the install Wcto2012- after the install
Wcto2012- after the install Al Davis
 
WordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPressWordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPressAl 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 2012Al Davis
 
Sharedhosting and WordPress
Sharedhosting and WordPressSharedhosting and WordPress
Sharedhosting and WordPressAl Davis
 
Shared Hosting and WordPress
Shared Hosting and WordPressShared Hosting and WordPress
Shared Hosting and WordPressAl Davis
 
Why use wordpress- ACP
Why use wordpress- ACPWhy use wordpress- ACP
Why use wordpress- ACPAl Davis
 
Onlinehub chicago- ACP
Onlinehub  chicago- ACPOnlinehub  chicago- ACP
Onlinehub chicago- ACPAl Davis
 
Wordpress beyond the blog
Wordpress  beyond the blogWordpress  beyond the blog
Wordpress beyond the blogAl Davis
 
Hosting provider
Hosting providerHosting provider
Hosting providerAl Davis
 

Plus de Al Davis (16)

Word camp Toronto 2017
Word camp Toronto 2017Word camp Toronto 2017
Word camp Toronto 2017
 
Montreal word camp 2017
Montreal word camp 2017Montreal word camp 2017
Montreal word camp 2017
 
Wcto2014
Wcto2014Wcto2014
Wcto2014
 
Wc boston
Wc bostonWc boston
Wc boston
 
New user guide
New user guideNew user guide
New user guide
 
Managing Multiple Authors with WordPress
Managing Multiple Authors with WordPressManaging Multiple Authors with WordPress
Managing Multiple Authors with WordPress
 
After the install
After the installAfter the install
After the install
 
Wcto2012- after the install
Wcto2012- after the install Wcto2012- after the install
Wcto2012- after the install
 
WordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPressWordCamp Atlanta- Shared Hosting and WordPress
WordCamp Atlanta- Shared Hosting and WordPress
 
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
 
Sharedhosting and WordPress
Sharedhosting and WordPressSharedhosting and WordPress
Sharedhosting and WordPress
 
Shared Hosting and WordPress
Shared Hosting and WordPressShared Hosting and WordPress
Shared Hosting and WordPress
 
Why use wordpress- ACP
Why use wordpress- ACPWhy use wordpress- ACP
Why use wordpress- ACP
 
Onlinehub chicago- ACP
Onlinehub  chicago- ACPOnlinehub  chicago- ACP
Onlinehub chicago- ACP
 
Wordpress beyond the blog
Wordpress  beyond the blogWordpress  beyond the blog
Wordpress beyond the blog
 
Hosting provider
Hosting providerHosting provider
Hosting provider
 

Introduction to WordPress Template Hierarchy

  • 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

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n