Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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...
Question?



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




                               sidebar.php




                        ...
The requirements

To build a functioning WordPress theme you need the following
files:

          index.php

          sty...
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 f...
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
...
Category page example

Wordpress looks for the following:

      1. category-{slug}.php - in this example it would be cate...
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.in...
Page Display
1.Custom template file- the page template assigned to the page
  ( example : alsawesometemplatefile.php)

2.p...
Author Display (last example)

1.Author-{nicename}.php If the author was dallas (my dog), the file
  would be author-dalla...
The forgotten templates....



1. Tag Display


2. 404 Display


3. Custom Taxonomies Display


4. Custom Post Types Displ...
Questions?
Upcoming SlideShare
Loading in …5
×

of

Intro to template hierarchy  WCTO Slide 1 Intro to template hierarchy  WCTO Slide 2 Intro to template hierarchy  WCTO Slide 3 Intro to template hierarchy  WCTO Slide 4 Intro to template hierarchy  WCTO Slide 5 Intro to template hierarchy  WCTO Slide 6 Intro to template hierarchy  WCTO Slide 7 Intro to template hierarchy  WCTO Slide 8 Intro to template hierarchy  WCTO Slide 9 Intro to template hierarchy  WCTO Slide 10 Intro to template hierarchy  WCTO Slide 11 Intro to template hierarchy  WCTO Slide 12 Intro to template hierarchy  WCTO Slide 13 Intro to template hierarchy  WCTO Slide 14 Intro to template hierarchy  WCTO Slide 15 Intro to template hierarchy  WCTO Slide 16 Intro to template hierarchy  WCTO Slide 17 Intro to template hierarchy  WCTO Slide 18 Intro to template hierarchy  WCTO Slide 19
Upcoming SlideShare
Marcus Andersson
Next
Download to read offline and view in fullscreen.

2 Likes

Share

Download to read offline

Intro to template hierarchy WCTO

Download to read offline

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Intro to template hierarchy WCTO

  1. 1. INTRODUCTION TO THE TEMPLATE HIERARCHY Al Davis- WordCamp Toronto Developers
  2. 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. 3. Question? What file does WordPress use to display a specific type of content?
  4. 4. Answer:
  5. 5. But first the basics header.php sidebar.php The Loop footer.php
  6. 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. 7. So what’s with all these files in a theme then?
  8. 8. Welcome to the Template Hierarchy How does it all work?
  9. 9. Home page example If a visitor goes to your home page at www.example.com/yourblog WordPress does the following:
  10. 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. 11. It’s a Rule!! When no other template files exist, WordPress will always display index.php Always
  12. 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. 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. 14. Lather , rinse , repeat WordPress follows this logic for all content types with just minor changes
  15. 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. 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. 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. 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
  19. 19. Questions?
  • msfernandes71

    Jul. 23, 2013
  • TantienHime

    Nov. 4, 2012

Views

Total views

4,062

On Slideshare

0

From embeds

0

Number of embeds

27

Actions

Downloads

8

Shares

0

Comments

0

Likes

2

×