Beginner’s Guide to WordPress Template Hierarchy (Cheat Sheet)

After our infographic on how wordpress works in the assist of the scenes, various customers asked us to duvet how a wordpress theme works in the assist of the scenes.

Listed right here, we are able to display the wordpress template hierarchy for inexperienced persons. This cheat sheet is amazingly vital when customizing a template or rising a custom wordpress theme.

WordPress template hierarchy explained for beginners

Why Learn About wordpress Template Hierarchy?

All favorite wordpress subject issues consist of templates, stylesheets, javascript, and photography. Together these files alter how your assert appears to be like to the customers.

Linked: 9 belongings you would possibly well even want to stare for when choosing the correct wordpress theme to your assert.

wordpress has a mature template hierarchy. This blueprint that templates with obvious filenames delight in an impression on particular areas for your internet internet page. It also tells you what template title to spend for a particular item.

Hottest wordpress subject issues reach with templates to state category, date, archives, single posts, custom pages, and more. As a individual, that you just can assemble more templates by rising a child theme.

Having said that, let’s secure a stare at how this wordpress template hierarchy works in the assist of the scenes.

Visualizing wordpress Template Hierarchy (Cheat Sheet)

wordpress makes spend of a straightforward to fancy and meaningful pattern for template names. The visual cheat sheet below explains which template files are historical to state assorted pages on a wordpress assert.

Here’s a breakdown of which wordpress template files to edit for assorted pages in an everyday wordpress assert.

Which template files are historical by home internet page?

Site front page

Out of the box, wordpress shows your blog posts on the home internet page of your internet internet page. It is seemingly you’ll well perchance perchance also furthermore discipline it to spend a custom home internet page (in most cases identified as entrance internet page) by visiting Settings » Discovering out internet page in wordpress admin assert.

1. entrance-internet page.php – Whereas you are the spend of a static entrance internet page, then wordpress will first stare for this template file and spend it to state entrance internet page.

2. home.php – Whereas you are the spend of static entrance internet page, and likewise you don’t delight in entrance-internet page.php template for your theme, then wordpress will stare for home.php template. It can be historical to state default blog posts on homepage.

3. index.php – If entrance-internet page.php or home.php carry out no longer exist, then wordpress falls assist to index.php template to state homepage. This template is the default fallback template in wordpress to state any internet page.

Which template files are historical by single put up?

Single post page template

wordpress appears to be like for these files to state a single put up.

1. single-{put up-kind}-{slug}.php – Utilize this template to alter the state of a particular particular individual put up in any put up kind. To illustrate, if put up kind is ‘evaluation’ and the put up slug is acme-cell phone, then wordpress would stare for single-evaluation-acme-cell phone.php.

2. single-{put up-kind}.phpwordpress will then take a look at if there is a template to state this particular put up kind. To illustrate, if the put up kind is evaluation, then wordpress would stare for single-evaluation.php.

3. single.phpwordpress will then descend assist to single.php.

4. singular.php – This template adds one more fallback to state a single item from any put up kind.

5. index.php – At closing, as mentioned above, wordpress in the extinguish falls assist to index.php.

Which template files are historical by single internet page?

Static page template

wordpress pages are one in all the default put up sorts. They’re going to enable you to assemble static pages for your internet internet page somewhat than posts. Gape our files on the difference between posts vs pages.

1. Custom Page Template – The online page template assigned to the online page. Gape assemble a custom internet page template in wordpress.

2. internet page-{slug}.php – If the online page slug is contact-us, wordpress will stare to spend internet page-contact-us.php.

3. internet page-{id}.php – If the online page ID is 17, then wordpress will stare for a template file named internet page-17.php.

4. internet page.php – The template to state all static pages.

5. singular.php – This template is a default fallback to all single put up kind objects.

6. index.php – The default fallback template.

Which template files are historical by category archives?

Category archive template

wordpress makes spend of these files to state category linked pages in wordpress.

1. category-{slug}.php – This template is historical to state category archive internet page for a particular category. To illustrate, if category slug is opinions, then wordpress will stare for category-opinions.php template.

2. category-{id}.phpwordpress then appears to be like for a template with category ID. To illustrate, if category ID is 17, then wordpress will stare for category-17.php.

3. category.php – This is the default template to state all category archive pages in wordpress.

4. archive.php – This is the default template historical by wordpress to state any archive pages.

5. index.php – The default fallback template.

Which template files are historical by label archives?

Tag archive template

wordpress makes spend of these files to state label archive pages.

1. label-{slug}.php – If the label’s slug is fruits, wordpress will stare for label-fruits.php.

2. label-{id}.php – If the label’s ID is 17, wordpress will stare for label-17.php template.

3. label.php – The default template for label archives.

4. archive.php – The default template for any achive internet page.

5. index.php – The default fallback template.

Which template files are historical by custom taxonomy archives?

Custom taxonomy archive

Categories and tags are two default wordpress taxonomies. Customers may maybe well perchance also assemble their very possess custom taxonomies as neatly. Here is how wordpress appears to be like for templates to state custom taxonomy pages.

1. taxonomy-{taxonomy}-{term}.php – Whereas you would possibly well even delight in a custom taxonomy known as genre, and there is a term ‘thriller’, then wordpress will stare for taxonomy-genre-thriller.php.

2. taxonomy-{taxonomy}.php – If the taxonomy had been genre, wordpress would stare for taxonomy-genre.php.

3. taxonomy.php – The default template to state any custom taxonomy archives.

4. archive.php – The default fallback for all archive pages in wordpress.

5. index.php– The default fallback template in wordpress.

Which template files are historical by custom put up sorts?

Custom post type archive

Here is how wordpress appears to be like for templates to state custom put up kind archives.

1. archive-{post_type}.php – Whereas you would possibly well even delight in a put up kind is evaluation, wordpress will stare for archive-evaluation.php.

2. archive.php – The default template to state all archive pages in wordpress.

3. index.php – The default fallback template in wordpress.

Which template files are historical to state author archives?

Author archive

wordpress generates archive pages for each and each author for your wordpress assert. Here is how it appears to be like for author archive template.

1. author-{nicename}.php – If the author’s effective title is matt, wordpress will stare for author-matt.php.

2. author-{id}.php – If the author’s individual ID is 6, then wordpress will stare for author-6.php.

3. author.php – The default template historical to state author archive pages in wordpress.

4. archive.php – The default template to state all archive pages in wordpress.

5. index.php – The default fallback template in wordpress.

Which template files are historical to state date based mostly archives?

Date based archive

wordpress also shows your posts on date based mostly archive pages for months and years. Here is how it appears to be like for templates for these pages.

1. date.php – The default template for date based mostly archives.

2. archive.php – The default template historical to state author archive pages in wordpress.

3. index.php – The default fallback template in wordpress.

Which template files are historical to state search pages?

Search result page

1. search.php – The default internet page to state search results in wordpress.

2. searchform.php – The template to state a search get in wordpress.

3. index.php – The default fallback template in wordpress.

Which template files are historical to state 404 error pages?

404 Error page

The 404 error internet page is displayed when wordpress is unable to bag the requested converse. Gape our files on toughen your 404 internet page template.

1. 404.php – The default template to state 404 error internet page in wordpress.

2. index.php – The default fallback template in wordpress.

Which template files are historical to state attachment pages?

Attachment pages

1. MIME_type.php – Mime_type stands for file kind. To illustrate, image.php, video.php, utility.php.

2. attachment.php – The default template to state attachment pages.

3. single-attachment.php – To state a single attachment.

4. single.php – The default template to state single put up kind objects.

5. index.php – The default fallback template in wordpress.

Which template files are historical to state embeds?

Embeds

Since wordpress 4.5, that you just can spend templates to render a put up embedded into wordpress.

1. embed-{put up-kind}-{post_format}.phpwordpress will stare for a put up kind and put up structure template first. To illustrate, whenever you happen to may maybe well perchance even delight in a evaluation with video, then wordpress will stare for embed-evaluation-video.php.

2. embed-{put up-kind}.php – If the put up kind is evaluation, wordpress would stare for embed-evaluation.php.

3. embed.php – The default fallback for all embeds.

We hope this tutorial helped you be taught about the wordpress template hierarchy. It is seemingly you’ll well perchance perchance also furthermore want to gaze our list of the handiest hotfoot & drop wordpress internet page builders.

Whereas you in point of fact liked this text, then please subscribe to our YouTube Channel for wordpress video tutorials. It is seemingly you’ll well perchance perchance also furthermore bag us on Twitter and Fb.