Template Hierarchy

1
968

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:

  1. Matches every query string to a query type to decide which page is being requested (for example, a search page, a category page, etc);
  2. Selects the template in the order determined by the template hierarchy;
  3. 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:

  1. 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.
  2. If category-unicorns.php is missing and the category’s ID is 4, WordPress looks for a template file named category-4.php.
  3. If category-4.php is missing, WordPress will look for a generic category template file, category.php.
  4. If category.php does not exist, WordPress will look for a generic archive template, archive.php.
  5. If archive.php is also missing, WordPress will fall back to the main theme template file, index.php.

Visual Overview

 

 

Like
Love
4
البحث
الأقسام
إقرأ المزيد
أخرى
Best Monetization Strategies for Your App in 2025 to Boost Revenue
Launching an app is exciting — but turning it into a money-making machine? That’s...
بواسطة CodeRower Software Pvt Ltd 2025-07-03 14:47:09 0 778
الرئيسية
Tankless Water Heater Repair Cost Breakdown in 2025
  When your water suddenly runs cold or your system shows an error code, it’s time to...
بواسطة Jack 678 2025-06-20 05:27:11 0 919
Health
Surprising Truths About Cenforce 200 You Need to Know
Cenforce 200 is a powerful and widely recognized treatment for erectile dysfunction (ED), known...
بواسطة Nick Johans 2025-07-04 05:33:26 0 782
Film
PowerPlay
Hello friends, I want to tell you about a very cool casino for all players in Canada, Power Play,...
بواسطة Pepkostarko 2024-05-21 13:27:57 0 773
Film
2024 Popular Contemporary Art Exhibitions Worldwide
Delve into the vibrant world of contemporary art with a curated selection of exhibitions...
بواسطة WhatsOn Media 2024-06-25 10:50:04 0 913
Whatson Plus https://whatson.plus