• Skip to primary navigation
  • Skip to main content
  • Skip to footer
WPArena

WPArena

WPArena is a premium online resource site of WordPress and is focused on providing excellent WordPress Tutorials, Guides, Tips, and Collections.

  • News
    • Opinion
  • Tutorials
  • Reviews
    • Themes
    • Plugins
  • Comparisons
  • Collections
    • Education Themes
    • Genesis Child Themes
    • Best Responsive Themes
    • Medical WordPress Themes
    • Finance & Business Themes
    • Crowdfunding Themes
  • Resources
    • Inspiration
  • Services
WPArena » Tutorials
Tutorials

Understanding WordPress Templates Hierarchy For Rendering the View

Avatar of Noor Mustafa Raza Noor Mustafa Raza Updated: May 2, 2018

WordPress Template Heirarchy
FacebookTweetPinLinkedInEmailPrint

If you have a question, “how does WordPress figure out which template file to Use for Rendering the View?” here is the answer. WordPress theme has a hierarchy of template files and the index.php is the most important and required file.
If your theme doesn’t find any requested file, it moves down its hierarchy of template files to find the next most appropriate file to use.

750px Russian Matroshka no bg

Displaying a unique template file, you can create a file with a unique name. For example, If you want to render the view for a Category #786 of your blog, create a file with this name category-786.php, and WordPress will automatically use it.

Let’s take a look at the hierarchy flowchart below. In this table, you will understand the WordPress template hierarchy in detail.

Which Template File will WordPress Use

The Template Hierarchy

PAGE TYPE tries first > tries next tries last
404 404.php > index.php
SEARCH search.php > index.php
TAXONOMY taxonomy-{tax}-{term}.php > taxonomy-{tax}.php taxonomy.php> archive.php> index.php
HOME home.php > index.php
ATTACHMENT {mime-type}.php > attachment.php single.php > index.php
SINGLE signle-{post-type}.php > single.php index.php
PAGE {custome-template}.php > page-{slug}.php page-{id}.php> page.php > index.php
Category category-{slug}.php > category-{id}.php category.php> archive.php> index.php
TAG tag-{slug}.php > tag-{id}.php tag.php archive.php> index.php
AUTHOR author-{author-nicename}.php > author-{author-id}.php author.php > archive.php> index.php
DATE date.php > archive.php index.php
ARCHIVE archive.php > index.php
This post was orginally published on: October 9, 2010 and was updated on: May 2, 2018.
FacebookTweetPinLinkedInEmailPrint

Related Stories

  • How to Create Special Text Areas with CSS in WordPress Post

  • Ultimate Guide To Optimizing your WordPress Blog Posts

    Ultimate Guide To Optimizing your WordPress Blog Posts

  • Create a Custom Logo with Wix Logo Maker in 6 Steps

    Create a Custom Logo with Wix Logo Maker in 6 Steps

Avatar of Noor Mustafa Raza

Noor Mustafa Raza

Ex-Editor in chief

I am a WordPress Developer and Designer, author @WPArena. I am providing Free WordPress consultation and can help you to install WordPress in a secure way to small businesses and bloggers.

Reader Interactions

Share Your Thoughts Cancel reply

Before submitting your comment, we kindly ask that you read our comment policy. Your email address will remain confidential and will not be published or shared anywhere. If you subscribe, you will receive notifications regarding new comments.

Footer

Top

  • Services
  • Our Themes
  • Facebook
  • Twitter
  • Linkedin

Reviews

  • Beaver Builder Review
  • Beaver Themer Review
  • WP User Frontend Pro
  • Ninja Forms Review
  • MemberPress Review

More Reviews »

Resources

  • Best WordPress Plugins
  • WordPress Permalinks Structure
  • Email Management System
  • Envato Free Files
  • Advertise
  • Write for us
  • Disclosure
  • Terms
  • Privacy
  • Contact

Copyright © 2023 · All Rights Reserved · WPArena is a Project of TechAbout LLC.
We are not affiliated with Automattic or WordPress.

  • Advertise
  • Write for us
  • Disclosure
  • Terms
  • Privacy
  • Contact
Share this ArticleLike this article? Email it to a friend!

Email sent!