WordPress Template Hierarchy for Category Pages

WordPress has a powerful templating system. You can create a WordPress theme by using different templates for different sections of your website. WordPress looks for a template in a pre-defined hierarchical order when displaying any page. To display a category page, it looks for templates in this order.

category-slug.php → category-id.php → category.php → archive.php → index.php

First WordPress will look for a template specific for that particular category using the category slug, for example, category-design.php template will be used to display ‘Design’ category. If it does not find a category-slug template, then WordPress will look for a template with category id, for example category-6.php. After that it will look for the generic category template which is usually category.php. If there is no generic category template present, then WordPress will look for generic archive template, i.e. archive.php. Lastly it will use index.php template to display the category.

Leave Comment

Your email address will not be published. Required fields are marked *