Search⌘ K
AI Features

Template Hierarchy

Explore the WordPress template hierarchy to understand how the system chooses specific files to display different types of pages such as front page, single posts, archives, and error pages. This lesson helps you grasp the fallback sequence WordPress follows and how to customize themes by creating appropriate template files for various page types.

WordPress uses a template hierarchy which decides which file is used to display a given page. It defines the order in which the file is chosen.

Every page that WordPress shows comes from a template file. The hierarchy decides which file will be used. It has a series of fallback options in case a file is not available. All these fallback options end with index.php which is a necessary file for all themes. Theoretically speaking, only an index.php file can be used to create a fully functional theme. However, for the sake of customization, a theme contains different files that power different types of pages (home, blog, search, etc.) or different sections ...