---
title: "WordPress Template Hierarchy: How WordPress Chooses What to Display"
description: "Every time someone visits a page on your WordPress site, WordPress runs a quick behind-the-scenes decision process to figure out which file to use to display that page. This system…"
url: "https://wondanation.com/wordpress-template-hierarchy/"
type: "post"
date: "2026-11-29T02:06:48+01:00"
modified: "2026-11-29T06:49:04+01:00"
author: "Digital Hub Team"
---

# WordPress Template Hierarchy: How WordPress Chooses What to Display

Every time someone visits a page on your WordPress site, WordPress runs a quick behind-the-scenes decision process to figure out which file to use to display that page. This system is called the **wordpress template hierarchy**, and understanding it is the key to taking real control of how your site looks and behaves.

Most site owners never learn this. They wonder why their homepage looks different from their blog page, or why they cannot style a category page without breaking everything else. The answer almost always lives inside the template hierarchy.

This guide breaks it down in plain English, with real examples and practical steps you can take today. It covers classic PHP-based themes, which still power the majority of WordPress sites. Even if you have never touched a theme file before, you will leave with a clear picture of how the system works and exactly what to do next.

### **What Is the WordPress Template Hierarchy?**

The wordpress template hierarchy is WordPress’s built-in rulebook for deciding which theme file to load for any given page on your site.

Think of it like a waterfall. WordPress starts at the top with the most specific file it can find. If that file does not exist in your theme, it moves down to the next option. It keeps working its way down until it finds a file that exists. If nothing more specific is found, it falls back to **index.php**, which every theme is required to have.

Here is the simplest way to picture it:

**Most specific file → Less specific file → index.php**

For example, if someone visits a category page for “Marketing Tips,” WordPress checks for files in this exact order:

1. category-marketing-tips.php
2. category-5.php (using the category’s database ID)
3. category.php
4. archive.php
5. index.php

WordPress uses the first file it finds and stops looking. This logic applies to every page type on your site: single posts, standard pages, archives, search results, 404 error pages, and more.

**Key takeaway:** The template hierarchy gives you surgical control. You can create a completely custom layout for one specific category while leaving everything else on your site completely untouched.

### **Why the WordPress Template Hierarchy Matters for Your Business Site**

If you are building a business website, different pages need to do different jobs.

Your homepage needs to sell. Your blog needs to be readable and easy to scan. Your product or service pages need to convert visitors into leads. A contact page needs to be simple and trustworthy.

Without understanding the wordpress template hierarchy, you are stuck applying one design to everything, or fighting with page builder overrides that break whenever you update your theme.

With it, you can:

- Give your homepage a completely unique layout that no other page shares
- Style your blog archive differently from your individual category pages
- Create a custom look for a specific content type like case studies or testimonials
- Fix a broken page without touching any file that is currently working fine

Understanding the wordpress theme structure also makes troubleshooting much faster. Instead of guessing which file to edit, you know exactly where to look.

If you are just getting started, take a few minutes to read our WordPress Dashboard Tour: Understanding Your Site Backend first. It will help you get your bearings before you start working with theme files.

### **The Main Template Files and What They Control**

Here is a clear map of the most important template files wordpress uses in a classic theme, and which part of your site each one controls.

| Page Type | Template Files WordPress Looks For (In Order) |
| --- | --- |
| Homepage (static page) | front-page.php, page.php, index.php |
| Homepage (blog posts) | home.php, index.php |
| Single blog post | single-post.php, single.php, singular.php, index.php |
| Standard page | page-{slug}.php, page-{ID}.php, page.php, singular.php, index.php |
| Category archive | category-{slug}.php, category-{ID}.php, category.php, archive.php, index.php |
| Tag archive | tag-{slug}.php, tag-{ID}.php, tag.php, archive.php, index.php |
| Author archive | author-{nicename}.php, author-{ID}.php, author.php, archive.php, index.php |
| Search results | search.php, index.php |
| 404 error page | 404.php, index.php |
| Attachment page | {MIME-type}.php, attachment.php, single.php, index.php |

Beyond these page-level templates, most themes also include these supporting files that are loaded on every page:

- **header.php:** Controls your site header and navigation menu
- **footer.php:** Controls your footer content and widget areas
- **sidebar.php:** Controls sidebar content
- **functions.php:** Not a template file, but controls theme features and registers functionality
- **style.css:** Your main stylesheet, where all visual styling lives

**Key takeaway:** Every page type on your site has a specific chain of template files. Knowing this chain tells you exactly where to look when you want to make changes.

### **How to Find Which Template File Is Running on Any Page**

Before you edit anything, you need to confirm which file is actually running on a given page. There are two reliable ways to do this.

#### **Method 1: Use the Query Monitor Plugin (Recommended for Beginners)**

The easiest approach is to install a free plugin called **Query Monitor**. Once activated, it adds a debugging toolbar to the top of your site (visible only when you are logged in as an admin) that shows you:

- The exact template file currently being loaded
- All template parts included on the page
- The WordPress query running behind the scenes

To get started:

1. Go to **Plugins > Add New** in your WordPress dashboard
2. Search for “Query Monitor”
3. Install and activate it
4. Visit any page on your site while logged in as an admin
5. Click the Query Monitor bar at the top of the screen
6. Look under the “Template” section to see the active file

This takes about two minutes and removes all guesswork from the process.

#### **Method 2: Review Your Theme Files Manually**

If you prefer not to add a plugin, go to **Appearance > Theme File Editor** in your dashboard. You will see a list of all files in your active theme in the right-hand sidebar. Compare what you see against the hierarchy table above to figure out which file is responsible for the page type you want to change.

**Key takeaway:** Never edit a file blind. Always confirm which template is active before touching anything.

### **Step-by-Step: How to Customize Pages Using the Template Hierarchy**

Here are three practical use cases showing how to apply the template hierarchy directly to your own site.

#### **Use Case 1: Customizing Single Blog Post Pages**

You want your blog posts to have a unique layout, different from your standard pages. Perhaps you want a wider content area, a custom author bio box at the bottom, or no sidebar.

Here is what to do:

1. Check whether your theme already has a **single.php** file (use Query Monitor or the Theme File Editor)
2. If it does, this file currently controls all your single post pages
3. Set up a child theme first (covered in the next section) to protect your changes
4. Copy single.php into your child theme folder and make your edits there

For a deeper look at how to structure the content layout inside single posts, our guide on Blog Post Templates: Proven Structures for Different Content Types covers exactly that.

#### **Use Case 2: Giving One Category Its Own Layout**

Say you have a category called “Case Studies” and you want it to look completely different from your regular blog archive, perhaps with a grid layout instead of a list.

1. Find the category slug by going to **Posts > Categories** and checking the slug column. In this example it is “case-studies”
2. In your child theme folder, create a new file named **category-case-studies.php**
3. WordPress will now load this file only for that specific category
4. Copy the contents of your existing category.php into it as a starting point, then modify from there

Nothing else on your site changes. This is the template hierarchy working exactly as designed.

#### **Use Case 3: Custom Post Type Templates**

Custom post types like Testimonials, Services, or Portfolio Items follow their own template hierarchy chain. For a custom post type with the slug “services,” WordPress checks for:

1. single-services.php
2. single.php
3. singular.php
4. index.php

To give it a unique layout, add a file named **single-services.php** to your child theme. WordPress will find it first and use it automatically.

For a complete explanation of how custom post types work and when to use them, read our guide on Custom Post Types Explained: Organize Content Beyond Posts and Pages.

**Key takeaway:** You do not need to rebuild your entire theme to customize one section. The hierarchy lets you target exactly the file that controls the page you need.

### **Child Themes: The Right Way to Customize Template Files**

If you edit your theme’s template files directly, you will lose every change the next time the theme updates. This is one of the most common and costly mistakes WordPress beginners make.

The solution is a **child theme**: a separate folder that inherits everything from your main (parent) theme, but lets you safely override specific files. When the parent theme updates, your child theme files stay completely untouched.

Here is how to create one from scratch:

1. Connect to your site using **cPanel File Manager** or an FTP client like FileZilla
2. Navigate to **/wp-content/themes/**
3. Create a new folder. For example: **yourtheme-child**
4. Inside that folder, create two files: **style.css** and **functions.php**

Add this to the top of your **style.css** file:

css

/\*

Theme Name: Your Theme Child

Template: your-parent-theme-folder-name

\*/

Add this to your **functions.php** file to load the parent theme’s styles:

```
<?php
function yourtheme_child_enqueue_styles() {
    wp_enqueue_style(
        'parent-style',
        get_template_directory_uri() . '/style.css'
    );
}
add_action( 'wp_enqueue_scripts', 'yourtheme_child_enqueue_styles' );
```

5. Go to **Appearance > Themes** in your dashboard and activate your new child theme

From this point on, any template file you place inside your child theme folder overrides the matching file in the parent theme. Your customizations survive every update.

**Key takeaway:** Set up a child theme before you edit any template file. It takes about 15 minutes and protects everything you build going forward.

### **Block Themes and Full Site Editing: What You Need to Know**

If your theme uses the **Full Site Editing (FSE)** system introduced in WordPress 5.9, the template hierarchy works with the same logic but uses a different file format.

Instead of PHP files, FSE themes store templates as HTML files inside a **/templates/** folder. You edit them through the visual Site Editor rather than a code editor, and the wordpress theme structure is managed entirely through blocks.

WordPress still applies the same hierarchy rules: the most specific template takes priority. The difference is in how you create and edit those templates.

If you are using a block theme like Twenty Twenty-Three, or a builder like Kadence with FSE support, read our guide on Full Site Editing with Gutenberg: Edit Headers, Footers, and Templates for a full walkthrough of that system.

For classic themes, which still power the majority of active WordPress sites, everything covered in this article applies directly.

### **Troubleshooting: When Your Template Changes Are Not Working**

Here are the most common template file problems and how to solve each one.

**Problem: You created a custom template file but WordPress is ignoring it.**

Check the filename carefully. A single typo, such as category-casestudies.php instead of category-case-studies.php, means WordPress will skip the file entirely and fall back to the next option. Use Query Monitor to confirm which file is actually being loaded, then compare it against your intended filename character by character.

**Problem: Your edits are not showing up on the front end.**

Two likely causes. First, you may be editing the parent theme file instead of the child theme version. Check which folder you saved to. Second, your browser may be serving a cached version of the page. Do a hard refresh using Ctrl+Shift+R on Windows or Cmd+Shift+R on Mac.

**Problem: Your site went blank after editing a template file.**

This almost always means a PHP syntax error in the file you edited. Open the file again and look for a missing semicolon, an unclosed bracket, or an extra character. If you cannot spot it, restore the original file from a backup. This is another reason why regular site backups are not optional.

**Problem: A page builder is overriding your template.**

Page builders like Elementor and Divi often bypass the standard template hierarchy entirely and manage their own rendering system. In that case, you control the page layout from inside the builder, not through PHP template files. For pages built specifically to convert visitors, our guide on Conversion Rate Optimization Process: Systematic Improvement walks through how to structure and test those layouts for results.

If your goal is to communicate with visitors after they leave your site, check out our guide on Email Copywriting: Write Emails That Get Opened and Clicked for practical strategies on follow-up sequences.

### **Frequently Asked Questions**

 What is the WordPress template hierarchy in simple terms? 

It is the system WordPress uses to decide which theme file to load for any given page on your site. WordPress always looks for the most specific file first, then works its way down to index.php if nothing more specific is found. Knowing this gives you precise control over the layout of each page type.

 What is the most important file in the WordPress template hierarchy? 

index.php is the most important because it is the universal fallback. If WordPress cannot find any other matching template, it always loads index.php. Every theme must include this file to function correctly.

 How do I create a custom template for one specific page in WordPress? 

Create a PHP file in your child theme folder. At the very top, add this comment: /\* Template Name: My Custom Layout \*/. Then open the page in the WordPress editor, and select your new template from the Page Attributes panel on the right side of the screen.

 Can I use the template hierarchy with page builders like Elementor? 

Partially. Page builders often bypass PHP template files and manage their own layouts. That said, understanding the hierarchy still helps you control archive pages, search results, and 404 pages, which builders typically do not touch.

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

front-page.php is used exclusively for your homepage, whether it displays a static page or a blog feed. page.php is the template for all standard WordPress pages. When both files exist, front-page.php takes priority for the homepage only.

 How do I find out which template file is controlling a specific page? 

Install the free Query Monitor plugin. Visit any page on your site while logged in as an admin, and the toolbar will show you the exact template file being used. It is the fastest and most reliable way to identify which file to edit.

 Do I need to know PHP to work with the WordPress template hierarchy? 

Not for basic customisation. Copying an existing template file and making small layout changes requires minimal PHP knowledge. For more advanced modifications, some PHP familiarity helps. Beginners can also use theme settings or a page builder to achieve most layout goals without writing any code.

### **What to Do Next**

**Step 1: Install Query Monitor and map your current templates.** Visit your homepage, a single blog post, a category page, and a standard page while logged in. Write down which template file is loading for each. This gives you a complete picture of your current wordpress theme structure before you change anything.

**Step 2: Set up your child theme today.** Use the code and steps in this guide to create a child theme, even if you are not ready to customise anything yet. Having it in place means you are protected the moment you decide to make a change. It takes about 15 minutes and costs nothing.

**Step 3: Pick one page type to improve.** Choose the page type that matters most to your business right now: your blog archive, a key category, or a custom post type. Create the appropriate template file in your child theme and make one specific change. Small, targeted improvements compound over time.

**Step 4: Go deeper based on what your site needs.**

- Building content beyond standard posts: Custom Post Types Explained: Organize Content Beyond Posts and Pages
- Using a block theme or Gutenberg: Full Site Editing with Gutenberg: Edit Headers, Footers, and Templates
- Improving your blog post layout: Blog Post Templates: Proven Structures for Different Content Types
- Adding reusable content elements: WordPress Shortcodes: Create Reusable Content Elements
