Template Hierarchy
Postado 2022-11-18 04:47:47
1
785

Overview
WordPress uses the query string to decide which template or set of templates should be used to display the page. The query string is information that is contained in the link to each part of your website.
Put simply, WordPress searches down through the template hierarchy until it finds a matching template file. To determine which template file to use, WordPress:
- Matches every query string to a query type to decide which page is being requested (for example, a search page, a category page, etc);
- Selects the template in the order determined by the template hierarchy;
- Looks for template files with specific names in the current theme’s directory and uses the first matching template file as specified by the hierarchy
Examples
If your blog is at http://example.com/blog/
and a visitor clicks on a link to a category page such as http://example.com/blog/category/your-cat/
, WordPress looks for a template file in the current theme’s directory that matches the category’s ID to generate the correct page. More specifically, WordPress follows this procedure:
- Looks for a template file in the current theme’s directory that matches the category’s slug. If the category slug is “unicorns,” then WordPress looks for a template file named
category-unicorns.php
. - If
category-unicorns.php
is missing and the category’s ID is 4, WordPress looks for a template file namedcategory-4.php
. - If
category-4.php
is missing, WordPress will look for a generic category template file,category.php
. - If
category.php
does not exist, WordPress will look for a generic archive template,archive.php
. - If
archive.php
is also missing, WordPress will fall back to the main theme template file,index.php
.
Visual Overview


Pesquisar
Categorias
- Art
- Causes
- Best Offers
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- Jogos
- Festival
- Gardening
- Health
- Início
- Literature
- Music
- Networking
- Outro
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness
Leia Mais
Why Gurgaon's Coworking Spaces are the Ultimate Productivity Boosters for Freelancers?
In today’s dynamic work environment, freelancers are increasingly seeking spaces that not...
Floor Plan Creator for Commercial Spaces Offices Shops and Cafes
XTEN-AV has transformed the way professionals design and visualize spaces by providing tools that...
Elevate Your Culinary Experience with Tandoor Morni Ovens
Cooking is not just about preparing food—it is about creating experiences, celebrating...
Olefins and Aromatics Market Overview: Growth, Share, Value, Size, and Scope
"Executive Summary Olefins and Aromatics Market :
Data Bridge Market Research analyzes...
WhatsOn Celebrates Mental Health Awareness Week!
This Mental Health Awareness Week gives all of us a chance to raise the consciousness of topics...
© 2025 Whatson Plus
Portuguese
