What's WP
Find Everything Related to WordPress - Best Tutoriasl on WordPress!
Comprehensive Beginners' Guide on WordPress Category Template

Comprehensive Beginners’ Guide on WordPress Category Template

If you have been browsing the internet in recent days, you might have noticed that some sites use different layouts for each of the categories. It has been made possible by WordPress through theme development where each category, post types, tags and taxonomies have different templates.

This has been made a common practice by many WordPress site owners as it makes their site look elegant and easy to manage. The WordPress category template allows your visitors to subscribe to a specific category, add images to that category and view category descriptions.

In the following, we have come out a detailed beginner guide about WordPress category template.

Introduction to Category Template on WordPress

Many sites online have different categories for their content. A blog may have travel, creative, people and many other categories as the blogger wishes. Visitors click on a category and can be directed to the category page where all the posts on that category are displayed chronologically; the latest articles at the top place and the earlier at the bottom. There are different ways of displaying the posts; you can include the date and the name of the author and can also decide to include the whole post or just an excerpt of the post.

There is a default way in which each theme you choose displayed the posts, but you can decide to customize the display to meet your taste. Themes files are used to change the display when a visitor clicks on a category. After changing the display, you can go to Permalinks settings to set the permalinks to the category archives.

Template File Selection

The first step in changing the display is to select the theme’s file to use in changing the posts display. This is referred to as Template Hierarchy, which is simple in the categories.

There are different theme files that can be used to change the display including category-slug/id.php, category.php. archive.php and index.phpin that order.

For instance, if the slug of your category can be found, then the first one of the above template files in your Theme directory will be used. If the slug cannot be found, then it’s time for ID. This translates to creating a file for category-id.php if you need to have a category with the ID number.

Changing all category pages to achieve a different look from the archive pages requires you to create and modify category.php file. This is when you need to change date archives. If you need to change the archive pages, create and edit archives.php file. Index.php file is needed when you need to make changes to the entire blog.

Create a WordPress Category Template

As earlier mentioned, you need to create a category.php file and modify it. To do this, you need to open Appearance >> Editor from WordPress admin panel and select category.php.


If you do not have the category.php theme file, select the archive.php theme file. If you lack the two files, then you might be using a theme framework which you should refer to.

After locating any of the files above, copy its content and paste it in a text editor for instance notepad. Save the file as category-news.php. Using FTP client, connect to your site and go to WordPress-content >> themes >> current theme, and then select to upload the category-news.php to your wp directory. After uploading, any changes you make can take effect on the specific category only.

Note that the original file code looks like as following. Don’t go for the wrong files.

category.php code

For template header

template header

For category name

category name

For category description

category description

For template appearance

template appearance

You can create as many templates as you wish using the above method. You just need to save the file as category-(category slug).php. Slugs can be seen on the categories section in admin area.

If you want to add something different in your category template file, you can also refer to the advanced CSS knowledge. For instance, the use of that replaces the use of means that the posts will be displayed as excerpts instead of full posts. Showing excerpts for posts is a good idea as it gives your readers insights by showing them the description of many different posts.

You can also use the category ID instead of category slug to make changes to the WordPress category template and change the way posts are displayed on your site.

Customize the Category Template

Now, it’s time to make some customizations. You only need to edit this new template file using PHP, and save the changes. We have listed some common customizing examples in below, with which you can gain some design aspirations.

Add the same introductive text above posts

add the same introductive text above posts code

Add different texts on different category

add different texts on different category

Put category name at the top of the page

put category name at the top of the page

Display the post excerpts or the full posts

display the post excerpts code


display the full post code

You’d better place one of them after the code of

display the post excerpts or the full posts code

Replace the post content with a linked image

replace the post content with a linked image

Decide which category can be seen on any page

decide which category can be seen on any page

Use Conditional Tags to Change WordPress Category Template Display

Conditional tags can be used to create generic templates like archive.php or category.php. The changes are simple and can thus be accommodated in the conditional tags. WordPress has many conditional tags that theme developers can use to create the templates they need such as _category().

If you want to display extra information for this category, you need to add the following code.

Conditional Tags

Some bloggers may find the above a challenge for the first time, but it becomes fun after learning. There are a myriad of benefits for using a well-thought category on your website. The readers experience on your site can also be increased, and it keeps the readers engaged. Different displays give the blog a great taste and give your readers what they need in each category.


Joyce is a professional writer & SEOer who loves trying new things and sharing the experience through blogging. She loves clean design, playing with different WordPress themes, SEO, etc. Very often, you could find her in various WordPress event as invited speakers.