Which Template File does WordPress Use to Render Different Pages?

Posted on: February 19, 2010 by Chris Coyier

This page in the codex has a particularly interesting infographic that shows a flowchart of how WordPress chooses which template file it is going to use to render the page. For example, did you know if you have a published page with “contact” as the slug, it will look for and use page-contact.php automatically?

Unfortunately this graphic wasn’t very pretty and for some reason has a giant “Page 1″ text awkward sitting over it. We have an outdated version of this in the book, and since we are updating it right now, I thought I would take the opportunity to re-create this chart.

CLICK FOR FULL SIZE VERSION

This will also be used in the book, which should be back available for order in around a week or so! Stay tuned!

Thumb for Which Template File does WordPress Use to Render Different Pages?

Let's talk it out, folks.

  1. I thought there were more stuff with authors, a bit like tags or categories ?

    #1
    • There may be… I just redrew the chart available. If there is, I’d love to hear about it and update this.

      #1.1
      • Indeed there are author-{$author}.php and author-{$author_id}.php (see get_author_template() in wp-includes/theme.php)

        Basically I think everything you can think of just works now :)

        #1.1.1
      • I’m also hearing this will be out of date for v3.0, so will definitely need an update.

        #1.1.2
  2. I’m interested in where custom taxonomies and the 3.0 custom post-types will fit in.. Any happen to know off hand?

    #2
  3. It may not be perfect, but I really appreciate your sharing this. I’m not an expert at editing theme files, and this will help.

    #3
  4. Ethan said on February 19, 2010:

    In WP 3.0 I’m using single-contact.php for a custom post type “contact”.

    Thanks for the redesign, this is much easier on the eyes than the Codex’s version.

    #4
  5. Glad to hear its in the book and that the book will be back on sale soon. Looking forward to getting my mitts on it! :)

    #5
  6. you forgot the “ PAGE-{ID}.PHP ”.

    #6

Comments are closed. If you have something really important to add, contact us. Thank you!