Intro to template hierarchy WCTO

3,517 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,517
On SlideShare
0
From Embeds
0
Number of Embeds
24
Actions
Shares
0
Downloads
6
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • 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 ofcontent?
    4. 4. Answer:
    5. 5. But first the basics header.php sidebar.php The Loop footer.php
    6. 6. The requirementsTo build a functioning WordPress theme you need the followingfiles: index.php style.cssYour 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 HierarchyHow does it all work?
    9. 9. Home page exampleIf a visitor goes to your home page atwww.example.com/yourblogWordPress does the following:
    10. 10. Home page example1.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.php3.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 alwaysdisplay index.php Always
    12. 12. Category page exampleUser clicks on your link for a category page at:www.example.com/yourblog/category/cats-are-dumbWhat happens?
    13. 13. Category page exampleWordpress 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 , repeatWordPress follows this logic for all content types with just minorchanges
    15. 15. Single Post1.Single-{post-type}.php. If the post type was cars, it would look for single-cars.php2.single.php3.index.php
    16. 16. Page Display1.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.php3.page-{id}.php4.page.php5.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.php2.author-{id}.php3.Author.php4.Archive.php5.Index.php
    18. 18. The forgotten templates....1. Tag Display2. 404 Display3. Custom Taxonomies Display4. Custom Post Types Display5. Date Display6. Search Result Display7. Attachment Display
    19. 19. Questions?

    ×