Template Hierarchy

By default, WordPress sets your site’s home page to display your latest blog posts. This page is called the blog posts index. You can also set your blog posts to display on a separate static page. The template file home.php is used to render the blog posts index, whether it is being used as the front page or on separate static page. If home.php does not exist, WordPress will use index.php.

  1. home.php

  2. index.php

The front-page.php template file is used to render your site’s front page. If the front-page.php file does not exist, WordPress will either use the home.php or page.php files depending on the setup in Settings → Reading. If neither of those files exist, it will use the index.php file.

Work with either use latest post and static page homepage displays.

The privacy-policy.php template file is used to render your site’s Privacy Policy page. The Privacy Policy page template takes precedence over the static page (page.php) template. If the privacy-policy.php file does not exist, WordPress will either use the page.php or singular.php files depending on the available templates. If neither of those files exist, it will use the index.php file.

  • privacy-policy.php

  • page.php

  • singular.php

  • index.php

Rendering category archive index pages uses the following path in WordPress:

  1. category-{slug}.php – If the category’s slug is news, WordPress will look for category-news.php.

  2. category-{id}.php – If the category’s ID is 6, WordPress will look for category-6.php.

  3. category.php

  4. archive.php

  5. index.php

To display a tag archive index page, WordPress uses the following path:

  1. tag-{slug}.php – If the tag’s slug is sometag, WordPress will look for tag-sometag.php.

  2. tag-{id}.php – If the tag’s ID is 6, WordPress will look for tag-6.php.

  3. tag.php

  4. archive.php

  5. index.php

Search results follow the same pattern as other template types:

  1. search.php

  2. index.php

Likewise, 404 template files are called in this order:

  1. 404.php

  2. index.php

Last updated