WordPress Template Hierarchy System

What is Template Hierarchy System?

Template Hierarchy is WordPress built-in system that tells which files to load and in which order based on the content requested.

Template Hierarchy System - order

There are seven types of Ppages in WordPress: Front page, single page, single post, custom post type, search result pages, category and tag pages, 404 error pages. Each of these pages has its own hierarchy. The order in which WordPress is searching for front page files is: front-page.php, home.php and index.php. If WordPress doesn't find the first option it moves to the second and then to the third. For single posts the order is single.php, sigular.php and index.php. For single pages the order is page.php, singular.php and index.php. etc.

Template Hierarchy System - file naming conventions

The general rule in file naming convention is all lowercase letters and separate words with hyphens.

Summary

Whenever you use WordPress website, the CMS will see what type of page you're trying to access and then use the hierarchy to determine what template files to load. This approach gives you full control how each page of your site looks and saves your development process time.