WordPress hierarchy is the system WordPress uses to decide which theme template should display a particular page. When someone visits your site, WordPress identifies the type of request—such as a blog post, category archive, search results page, or 404 error—and looks for the most specific matching template. If that file is not available, WordPress works through a defined sequence of alternatives until it finds one it can use.
Understanding what WordPress hierarchy is helps you customize a site without creating unnecessary template files. It also makes troubleshooting easier: when a page looks different than expected, you can identify which template WordPress is likely loading and where a more specific file belongs.
What Is the WordPress Template Hierarchy?
The WordPress template hierarchy is the set of rules that determines which theme file renders each type of page. It works like a fallback system. WordPress starts by checking for a template tailored to the exact request. If that template does not exist, it checks for a broader template, then continues until it reaches the theme’s general fallback file, usually index.php in a classic theme.
For example, a category archive might first look for a file made for that specific category. If no such file exists, WordPress tries a general category template, then an archive template, and finally index.php. This means you can customize one category without changing how every other archive on your site looks.
The hierarchy is part of the WordPress template system. A template is responsible for presenting content, while WordPress determines which template is appropriate for the current request. Themes provide the files, and WordPress follows the hierarchy to select among them.
How WordPress Chooses a Template
When a visitor requests a URL, WordPress processes the request and builds a query describing the content or page type to show. It then uses that context to choose a template. The URL alone does not select a file; WordPress also considers information such as the requested post type, post name, category, taxonomy term, and whether the request is for the front page.
WordPress checks potential template files in order, starting with the most specific option. The first matching file that exists in the active theme is used. If none of the more specific files are available, the search continues through the fallback options. For classic themes, index.php is the final fallback and is required for a valid theme.
This fallback approach keeps themes flexible. A simple theme can rely on a small number of templates, while a more customized theme can add specific files for individual pages, content types, or archives.
Common WordPress Template Files
Classic WordPress themes use PHP template files. Their names often indicate the kind of content they display. Common examples include:
-
front-page.phpfor the site’s front page. -
home.phpfor the main blog posts index. -
single.phpfor individual posts when no more specific single-post template is available. -
page.phpfor individual pages. -
archive.phpfor archive pages, such as date or post type archives. -
search.phpfor search results. -
404.phpfor pages shown when requested content cannot be found. -
index.phpas the final fallback template.
A theme does not need to include every possible template. WordPress moves to the next available option when a file is missing. However, adding a dedicated template gives you more control over the design and content of that particular page type.
Key Parts of the WordPress Hierarchy
Front page and blog index
The front page is the homepage visitors see at your site’s main URL. If a theme includes front-page.php, WordPress uses it for the front page. This is true whether your homepage displays your latest posts or a static page.
The blog posts index is different from the front page when the site is configured to use a static homepage. WordPress looks for home.php to display the posts index and falls back to index.php if that file is missing. The distinction matters when you want a designed landing page and a separate page listing recent posts.
Single posts and custom post types
For an individual post, WordPress checks for a template specific to that post type and, where applicable, the individual post. It then considers broader options such as single-{post-type}.php, single.php, singular.php, and index.php.
For example, a custom post type registered as book can use single-book.php for all individual book entries. A more specific file can target an individual item, such as single-book-the-great-gatsby.php. This lets a developer give a particular post a unique layout without changing the rest of the post type.
Pages
For a standard WordPress page, the hierarchy can include a page-specific template such as page-about.php or a file based on the page’s ID, such as page-42.php. WordPress can then fall back to page.php, singular.php, or index.php.
Pages can also use a custom page template selected in the WordPress editor, when the theme provides one. This is useful for layouts such as a full-width landing page or a page without a sidebar. Custom page templates are distinct from the standard hierarchy filenames, so check the theme’s available template options when troubleshooting a page layout.
Category, tag, and taxonomy archives
Archive templates display groups of content. A category archive can use a file for a specific category, such as category-news.php, followed by broader options such as category.php, archive.php, and index.php. A tag archive follows a similar pattern with files such as tag.php.
Custom taxonomies can also have dedicated templates. For example, a taxonomy registered as genre may use taxonomy-genre.php. A taxonomy-specific term file can target a particular term. These templates make it possible to present different kinds of archive pages with layouts suited to their content.
Search results and 404 pages
WordPress uses search.php for search results when the theme provides it. If the file is missing, it falls back to index.php. When a requested URL does not match available content, WordPress uses 404.php if available, then falls back to index.php.
Dedicated search and 404 templates are helpful because they let you guide visitors. A search page can show useful result details, while a 404 page can offer navigation or a search box instead of leaving visitors at a dead end.
Template Hierarchy in Block Themes
Block themes use the same general idea of template selection, but their templates are HTML files made from blocks rather than PHP files. These templates are usually stored in the theme’s templates directory. Examples include single.html, page.html, archive.html, and index.html.
Block themes also support more specific template names that correspond to WordPress content types and archives. When WordPress identifies a request, it looks for a suitable block template and uses a broader fallback if no specific option is available. The Site Editor lets users edit many of these templates visually.
One important difference is that a template customized and saved through the Site Editor may be stored in the WordPress database. That saved version can take priority over the original template file in the theme. As a result, changing a theme’s HTML file may not change the visible design if a customized version is already being used.
How to Find the Template Used on a Page
If you are unsure which file controls a page, first identify the page type. Is it the front page, an individual post, a page, a category archive, a search result, or a 404? Then use the corresponding hierarchy to identify likely template files, starting with the most specific filename.
For a practical check, you can temporarily add a visible comment or a small design change to a suspected template and refresh the page. Always test changes on a staging site or make a backup first. Developer tools and theme debugging plugins can also help reveal the template being loaded, but avoid leaving diagnostic output visible to visitors.
In a block theme, open the Site Editor and check the Templates section. If a template has been customized, review the saved version there as well as the theme files. This can explain why edits to a file are not appearing on the front end.
Best Practices for Working With Template Hierarchy
- Use the most specific template that matches the design change you want to make.
- Keep
index.phpin a classic theme so WordPress has a final fallback. - Use a child theme for PHP template changes when you need to preserve customizations through parent theme updates.
- Follow WordPress filename conventions carefully; a misspelled or incorrectly named file will not be selected.
- Use template parts for reusable sections, such as headers and footers, rather than duplicating the same markup across many templates.
- Test important page types after changing templates, including mobile layouts and archive pages.
- For block themes, check whether a Site Editor customization is overriding the file you edited.
Template parts and the template hierarchy work together, but they are not the same thing. The hierarchy selects the main template for a request. A template can then include reusable pieces, such as a header, footer, or post card, to keep the theme consistent and easier to maintain.
Why WordPress Hierarchy Matters for SEO
The hierarchy does not directly improve search rankings by itself, but it gives you control over how important pages are presented. A well-designed archive can make related posts easier to browse, and a useful 404 page can help visitors find the information they need. Clear templates can also support consistent headings, navigation, and structured page layouts.
Good template organization can make site maintenance more efficient, too. When you know which file controls a page type, you can improve its design or performance without making unrelated pages behave differently. Always make sure template changes preserve accessible markup, readable content, and a good experience on mobile devices.
Conclusion
WordPress hierarchy is the rules-based system WordPress uses to select a theme template for each request. It starts with the most specific matching file and falls back to broader templates until it finds one that exists. Knowing the hierarchy helps you customize posts, pages, archives, and special screens with greater precision.
Whether you work with a classic theme or a block theme, the key is to identify the page type, understand its fallback options, and edit the right template. With that knowledge, you can build a more consistent WordPress site, troubleshoot layout issues faster, and make targeted changes without affecting every page.