Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

WordPress determines the request type, checks that view’s templates in a fixed order, and renders the first matching file. In a classic theme this usually means PHP files such as single.php or archive.php; in a block theme it means HTML block templates, normally in /templates. The broad fallback is index.php for classic themes or templates/index.html for block themes.

How does the WordPress template hierarchy work?

WordPress does not consult one universal list for every URL. It first identifies what the request represents—such as the front page, posts index, a single post, a page, a taxonomy archive, search results, or a 404 response. It then walks the ordered hierarchy for that request and stops at the first template that exists.

The official classic-theme documentation describes the logic as “the logic WordPress uses to decide which theme template file(s) to use, depending on the content being requested.” See the classic template hierarchy handbook for the complete set of branches.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A simple example: category archives

For a category whose slug is news and whose term ID is 7, a classic theme is checked from most specific to least specific:

  1. category-news.php
  2. category-7.php
  3. category.php
  4. archive.php
  5. index.php

If category-news.php is absent, WordPress tries the next candidate. Adding that file later makes it the active template for that category without changing the others.

Which template file does WordPress use?

The answer depends on the view being requested. These are common classic-theme paths; every branch ultimately falls back to index.php when no more-specific file is present.

Front page and posts index

front-page.php has priority for the site front page. The posts index is a separate concept and is rendered through home.php, whether the posts list is also the front page or is assigned to a separate page under Settings → Reading. That distinction is why editing home.php may not change a static front page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pages

For a page request, the classic sequence begins with an assigned custom page template, then:

  1. page-{slug}.php
  2. page-{id}.php
  3. page.php
  4. singular.php
  5. index.php

For example, a page with the slug contact can use page-contact.php; a page with ID 42 can use page-42.php.

Single posts and other singular content

Single posts and other singular post types follow their own specificity rules, typically moving from a post-type or post-specific template to single.php, then singular.php, and finally index.php. Use the branch for the actual post type rather than assuming a page template will apply.

Taxonomy, search, and 404 views

Taxonomy archives can use term-specific, taxonomy-specific, archive.php, and then index.php fallbacks. Search results have a search.php branch, and a missing URL uses 404.php before the general fallback. The exact candidate names and order are documented in the classic hierarchy reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Classic themes versus block themes

The conceptual hierarchy is shared, but the file format and lookup locations differ. WordPress’s block-theme documentation is available in the block template hierarchy reference.

Topic Classic theme Block theme
Template format PHP files combining markup, template tags, and PHP HTML files containing block markup
Typical location Commonly the theme root; classic themes do not require a templates folder /templates for templates and /parts for reusable parts
Fallback index.php templates/index.html
Header and footer reuse Often header.php, footer.php, and sidebar.php included by template functions Template-part blocks referencing files in /parts
User-edited template priority The hierarchy primarily resolves theme and child-theme files A saved template in the database is checked before applicable child-theme and parent-theme files

In block themes, templates use blocks instead of PHP template tags. The theme’s index.html is the required catch-all, but a saved template created in the Site Editor can take precedence over the bundled file. The documented lookup order includes a saved database template, then a child theme’s /templates directory when applicable, and then the parent theme’s /templates directory. See WordPress’s templates documentation for the file and directory model.

What is the difference between front-page.php and home.php?

front-page.php controls the site front page in a classic theme and takes precedence there. home.php controls the posts index—the view that lists blog posts. Those views can be the same URL or two different URLs, depending on the Reading setting.

In a block theme, front-page.html has the corresponding front-page role. The remaining resolution follows the home or page hierarchy according to whether the site is configured to show latest posts or a static page. Do not translate a classic filename directly into a block-theme filename: block templates are HTML files in /templates.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How child themes affect precedence

A same-named file in a child theme overrides the parent theme’s counterpart. Specificity still matters, however: a more-specific parent template can be selected before a less-specific child template. For example, a parent theme’s page-contact.php can win over a child theme’s generic page.php, because the slug-specific candidate appears earlier in the hierarchy. Check both themes before concluding that a child file is being ignored.

Why is my WordPress template not being used?

Work through the request context and lookup sources in this order:

  1. Identify the actual view. Decide whether the URL is the front page, posts index, singular page or post, taxonomy archive, search results, 404, or another supported view.
  2. Follow that view’s hierarchy. A page, front page, and posts index do not necessarily use the same path.
  3. Confirm the theme type and extension. Look for PHP files in a classic theme’s usual locations, or HTML block templates under /templates in a block theme.
  4. Check saved block templates. In a block theme, open the Site Editor and inspect whether a user-saved template exists; the database version can outrank the file shipped with the theme.
  5. Check child and parent themes. Compare both files and account for specificity, not just filename matching.
  6. Inspect the fallback. If no earlier candidate exists, edit the active theme’s index.php or templates/index.html, as appropriate.

Plugins, custom filters, the active theme, and the installed WordPress version can also affect what you observe. Validate a diagnosis against the site’s current configuration rather than assuming a filename alone determines the output.

Where to learn the complete hierarchy

Use the official classic-theme hierarchy and block-theme hierarchy references when you need a less common branch, such as author archives, date archives, attachments, or custom post types. The separate page-template documentation explains assigned custom page templates, while theme-file organization guidance covers common classic-theme file locations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.