Template Hierarchy
Last updated
Last updated
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
.
home.php
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:
category-{slug}.php
– If the category’s slug is news
, WordPress will look for category-news.php
.
category-{id}.php
– If the category’s ID is 6
, WordPress will look for category-6.php
.
category.php
archive.php
index.php
To display a tag archive index page, WordPress uses the following path:
tag-{slug}.php
– If the tag’s slug is sometag
, WordPress will look for tag-sometag.php
.
tag-{id}.php
– If the tag’s ID is 6
, WordPress will look for tag-6.php
.
tag.php
archive.php
index.php
Search results follow the same pattern as other template types:
search.php
index.php
Likewise, 404 template files are called in this order:
404.php
index.php