How to create Category Templates in WordPress

Categories playing a major role in WordPress. It is more important in Blogs as well as most of the web sites nowadays. You can have any number of categories for your site. WordPress category is flowing from specific category template to common index page design. If you have referred to the Template Hierarchy you should aware of this. If you haven’t refer the WordPress Template Hierarchy I am highly recommending you to refer the WordPress Template Hierarchy now. Its order as follow.

  1. category-slug.php
  2. category-id.php
  3. category.php
  4. archive.php
  5. index.php

This is the flow of categories. First WordPress searching for the term name. Assume you have a category called Books and you have specific category page design for Books. Therefore you should have a page called category–books.php. If so its loading when you are referring books category. Assume you do not have the mentioned page and your books category ID is 13. Lets say we have category page called category–13.php this will take as the book category template because we do not have the book category page which match to the book category slug.

Whatever it is if you do not have a specific page for categories and when ever you have category.php it is the category template for your all categories. If you do not have category.php WordPress then searching for archive.php file to load your categories. After the category.php WordPress then looking for this file as per the hierarchy showing. If the archive.php file does not exists it is WordPress consider the index.php file as the category template file. If you wonder what happens if index.php file does not exists. Then I have to say you should aware about WordPress more. Because index.php is a compulsory page for WordPress. That means it is never does not exists and it is always exists.

You may also like...

Leave a Reply

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