WordPress Template Hierarchy Explained

This post attempts to give anyone wanting to learn the basics of WordPress a good start. In order to be able to successfully use the full potential of WordPress as a Content Management System it is essential to understand how to create a file structure for posts, pages, categories, tags, taxonomies of other kinds and more.

Wordpress template hierarchy tree view

Home

  1. home.php
  2. index.php

Single Posts

  1. single-{posttype}.php
  2. single.php
  3. index.php

Pages

  1. {pagename}.php (custom template)
  2. page-{slug}.php
  3. page-{id}.php
  4. page.php
  5. index.php

Category

  1. category-{slug}.php
  2. category-{id}.php
  3. category.php
  4. archive.php
  5. index.php

Taxonomy

  1. taxonomy-{taxonomy}-{term}.php
  2. taxonomy-{taxonomy}.php
  3. taxonomy.php
  4. archive.php
  5. index.php

Tag

  1. tag-{slug}.php
  2. tag-{id}.php
  3. tag.php
  4. archive.php
  5. index.php

Date

  1. date.php
  2. archive.php
  3. index.php

Archive

  1. archive.php
  2. index.php

Attachment

  1. {MIME_type}.php (text.php, image.php, audio.php, video.php)
  2. attachment.php
  3. single.php
  4. index.php

Author

  1. author-{nicename}.php
  2. author-{id}.php
  3. author.php
  4. archive.php
  5. index.php

Search

  1. search.php
  2. index.php

404

  1. 404.php
  2. index.php

Graphics and info taken from the WordPress codex.


Leave A Comment