ASCII WordPress Template Hierarchy

Last updated for WordPress 4.9.

Did you know that the index.php file in a WordPress¬†theme can be empty? There’s no need for it to contain anything at all, as long as you have the¬†following template files in place:

  • 404.php
  • search.php
  • front-page.php
  • home.php
  • singular.php
  • archive.php

When I build a theme from scratch, I make sure it includes at least these files. That means the index.php file will never get loaded, and I can put my beautiful ASCII WordPress template hierarchy diagram in it instead.

You can also use my Query Monitor plugin to view the actual hierarchy used to select the template for any given request, which makes working with the template hierarchy considerably easier.

One thought on “ASCII WordPress Template Hierarchy

Leave a Reply

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