Template Hierarchy

WordPress Template Hierarchy

WordPress Template Hierarchy (updated 2011.11.11)

Latest (and hopefully, final) Revision (8)

WordPressTemplateHierarchy Rev 8

WordPressTemplateHierarchy (Rev 8)

Previous Revision (7)

WordPressTemplateHierarchy Rev 7

WordPressTemplateHierarchy (Rev 7)

Previous Revision (6)

WordPressTemplateHierarchy Rev 6

WordPressTemplateHierarchy (Rev 6)

Previous Revision (4)

WordPressTemplateHierarchy Rev 4

WordPressTemplateHierarchy (Rev 4)

Previous Revision (3)

WordPress Template Hierarchy Rev 3

WordPress Template Hierarchy (Rev 3)

Previous Revision (2)

Template Hierarchy rev2

WordPress Template Hierarchy - Revision 2

First Revision (1)

WordPress Template Hierarchy

WordPress Template Hierarchy



34 Responses to “Template Hierarchy”
  1. johnbillion says:

    Good work Chip! This is a really nice improvement.

    There’s an error though (looking at rev 3). The is_tax() conditional isn’t true for category and tag archives as the diagram states. The “Taxonomy Archive” block should be removed, and the “Category Archive”, “Tag Archive”, and “Custom Taxonomy Archive” blocks should be moved up to the same level as “Date Archive”, “Author Archive” and “Custom Post Type Archive”.

    Also the “Custom Post Type Archive” block can have “post-type-archive post-type-archive-$posttype” added for its body classes.


  2. Rev. Voodoo says:

    Nice work there! That looks far better than the ‘running’ chart I had on a word doc. That’s going to be very helpful, I reference people to the old diagram very frequently… with much further explanation. I’ll definitely appreciate the update!

  3. Ed says:

    Great enhancements Chip!

    How would Post Formats be accounted for in the revised hierarchy?

    I’m increasingly using get_template_part and finding it’s a really smart way of loading different post format templates with minimal code (e.g. )

    Does get_template_part belong in your hierarchy at all?


    • Chip Bennett says:


      How would Post Formats be accounted for in the revised hierarchy

      I’ve not accounted for Post Formats separately in the template hierarchy, mainly because they are a taxonomy, and are accounted for in the Custom Taxonomy Archive hierarchy. Do you think it would be worth adding a separate hierarchy for Post Formats, specifically?

      Does get_template_part belong in your hierarchy at all?

      No, it wouldn’t belong. The Template Hierarchy is for template files. Template-part files, including those added via get_header(), get_footer(), get_sidebar(), and get_template_part() are files that are called from within template files. In other words, template files are the files that WordPress directly attempts to load from within core.

      • Ed says:

        Hey Chip – sorry about the late reply. Thanks for the points of clarification around Post Formats and get_template_part. Both make perfect sense. The Post Formats one might catch a lot of newer theme developers out before it slowly dawns on them that they are indeed taxonomies!

        The latest revisions are looking pretty amazing. I could spend the day studying it if I had the time!


  4. WPoets says:

    Thanks chip for taking time to draw these images. This is really useful for beginners and me ๐Ÿ™‚

  5. David says:

    thank you for this.
    btw, is it necessary to put another template file in there?
    like header.php footer, sidebar, etc,
    with get template part or something..?

  6. kaiser says:

    I guess for comments template, you can add is_comments_popup(). Thanks for the work ๐Ÿ™‚

  7. kaiser says:

    Hm. And I think paged.php is triggered before archive.php? Would wonder if the fallback really is the paged.php file and doesn’t override archive.php.

  8. kaiser says:

    First: You can delete my comments as the will (maybe) target “old” revisions. Two things: Below is_attachment() you got one arrow that’s leading to nothing. And for CPTarchive it’s missing the arrow.

    • Chip Bennett says:

      No worries; all comments welcome! I did fix that, but haven’t uploaded a new version. I think this one is fine for getting any final comments/changes, and don’t want to bother people too often with minor, iterative changes.

  9. kaiser says:

    I updated Codex to link to this page too – in case you want to blame someone for re-routing codex traffic ๐Ÿ™‚

  10. Dave Doolin says:

    Thanks, Chip. I know how much work goes into these types of diagrams, people who haven’t done it rarely realize that.

    As it turns out, I’m working on a theme which implements every permutation of template listed in the Codex diagram. This is just for learning and “proof testing” for anyone digging around in the template system. It’s not a “public” theme in the sense that it will be submitted to the WordPress theme repository. Rather it’s open sourced on Github. I’ll definitely be using your diagram here for more in-depth reference.

    The synchronicity on this material is awesome… once something decides it needs doing, many people come to the same conclusion, independently!

  11. Taylor says:

    Nicely done, This one’ll be printed and sitting up next to my desk. Cheers!

  12. marquex says:

    Hi Chip!

    Thanks for your effort, it is really useful for template makers! Don’t you think that wordpress template hierarchy y too complex and has nosense checks in it?

    For example: paged templates is useless if it is called after archive template.

    And attachements templates go from the more general to the more specific one ยฟ??

    I think WP should review it template selection system, and I’m thinking about creating a theme with a more comprehensible hierarchy.

  13. Is there a reason this doesn’t just take the place of the image on the codex?

    • Should have led that with:

      Great Job! This is a GREAT way for people to better understand what’s happening behind the scenes.

    • Chip Bennett says:

      Mika requested that I trim out some of the info (body classes, conditional tags) for the the replacement image for the current Codex image, along with a link to this “advanced” version. I just haven’t had the chance to polish up the trimmed-down version yet. ๐Ÿ™‚

  14. Cristian says:

    Hi Chip,

    Great job on the new template hierarchy.

    I would like to make modifications to it but your license says No Derivative Works. Could you modify it to support Derivatives? I basically want to make it nicer(different fonts and boxes) and make it fit into a landscape A4 or Letter size page so it’s easier to print ๐Ÿ™‚

    I like the way it’s looking now, just that I also like pushing pixels now and then and this looks fun. I never designed a diagram before ๐Ÿ™‚


    • Chip Bennett says:

      Hi Christian,

      Thanks! I will fix the footer license declaration so that it’s clear, but everything that I publish WordPress-related is under GPL; so, feel free to modify and redistribute!

      Let me know if you need a version in .SVG, for easier manipulation.

  15. Sorry to be contrarian, but I don’t agree this is a clearer diagram than the old one on the codex. It probably would be if I could read it, but it’s far too small for all the print to be legible.

    Also a legend to explain what the different colours mean would help.

    Personally I’d rather have a simpler diagram with perhaps a link to something more detailed, like this, assuming it can be made large enough to read all the text.

    Just my 2c (dwy geiniog Gymreig)

    • Chip Bennett says:


      No worries; constructive criticism is always welcome! A couple points, though: one, I did add a simplified version to the Codex, with a link to this more “advanced” version; and two, did you try clicking through to the full-sized image? I’m fairly certain that the full-sized version is big enough for just about anyone to read. ๐Ÿ™‚


  16. mua sam vui says:

    thanks ! it’s great construct, make a theme for wordpress is so easy !

  17. Kyle Krafka says:

    Thanks for your contribution! One thing that this chart doesn’t seem to answer is how multiple conditional tags triggered. For example, is_singular() and is_front_page() seem to be mutually exclusive, but they’re not, as I have a page that returns both as true. Any direction on this would be helpful. (Are is_front_page() and is_home() just two special cases?)

    • Chip Bennett says:

      It is difficult to balance the detail against potential complexity/confusion. In this iteration of the Template Hierarchy, I opted to follow the decision tree in template-loader.php, and then add in as much additional detail as I could. Regarding is_singluar() and is_front_page() specifically: you’d have to look at the query itself, but it makes sense; after all, a static front page is a page, and a page returns true for is_singular(). I’m guessing that, for the site in question, if you changed the settings such that the blog posts index were displayed on the site front page, then you would no longer return true for both is_front_page() and is_singular()?

  18. Josh Pollock says:


    This is awesome. I set it as the background on my second screen. Is there anyway you can email me the svg or post it somewhere? I’d like to better format it for 22inch widescreen.


  1. WordPress Template Hierarchie 2.0 - Schweizer WordPress Magazin
  2. Die Template-Hierarchie von WordPress | WordPress & Webwork
  3. Chip Bennett improves the template hierarchy diagram | WPCandy
  4. Improved Template Hierarchy Diagram « « rtCafe rtCafe
  5. Estructura completa de un theme de WordPress | ceslava | diseรฑo & cursos
  6. October WordPress Recap | Pioneer Valley Web Meetups
  7. Wordpress Kategorie Beschreibung anzeigen
  8. Jerarquรญa de Plantillas WordPress
  9. The Template File Hierarchy Of Wordpress - FLUROS
  10. WordPress Template Hierarchy - Codigonexo

Leave a Reply

Your email address will not be published. Required fields are marked *