Skip to content

Start typing to search services, software products, WordPress themes, portfolio projects and articles.

WordPress Theme Development

How WordPress chooses a template

Free preview 15 min

For every request, WordPress works out what is being asked for and then looks for templates in a fixed order, from most specific to least. A single post of type “book” tries single-book.php, then single.php, then singular.php, then index.php. The first file that exists wins.

Learning the hierarchy is mostly learning to stop fighting it. If you want a different layout for one category, you do not need conditional logic inside archive.php — you add category-slug.php and WordPress routes to it for you.

The same principle is how a well-built plugin lets a theme override its templates: it checks the theme for a matching file before falling back to its own.

Chat on WhatsApp