Easily Apply Templates to Your WordPress Category Pages
You may know that you can create templates for your category pages in order to make them unique. For example, if you have a category titled “Music,” you can make a template for that category (category-music.php) that you can then style differently.
But what if you had five categories that you wanted to look one way, five other categories you wanted to look another, and then five more you wanted to look yet another. Even though you only had three different designs, you would need to make fifteen separate category templates, one for each category.
A Simpler Solution
Luckily, there’s a simpler solution – a plugin called Custom Category Templates that lets you create multiple category templates that you can apply over and over again as you would a Page template.
So in our example above, instead of making fifteen different templates, you would only need to make three, and then apply the correct template to the correct categories.
How to Make a Category Template in 4 Steps
The plugin itself is very simple; however, some may not know how to make a category template, and so we’ll go over that first. If you already know how to make a category template, you can skip to the bottom to see the plugin in action.
You will need to create these category templates on your server.
Step 1: Copy Your Category.php File
In the folder of your theme (wp-content/themes/theme-name) find the file titled category.php. Open it and copy the contents, so you can use that as a starting point for your new category template.
Step 2: Create a New Category Template File
Create a new category template file and name it something descriptive. It MUST start with the word “category” and then a hyphen (“category-“). Also, it MUST end with a “.php” file extension.
In my example, I am going to put a banner in my template to make it different from the other categories, and so I’m going to name this category template “category-banner.php.”
(NOTE: Make sure you don’t name the file the same as a category on your site.)
Step 3: Paste Contents from Original Category File
Now, open the new file you’ve just created (category-banner.php) and paste the contents from your original category.php file into it.
Then, at the VERY TOP of that file, BEFORE EVERYTHING ELSE, put the following code with an appropriate name for your template. (In my case, I’m going to name this template “Banner.”)
<?php /* * Category Template: Banner */ ?>
Your file should look something like this.
Step 4: Edit Your New Category Template
Now you can edit your new category template to make it as you like.
In this example, I am going to add a banner to this template. This means that the banner I put in will show up on every category page that gets assigned this template.
Here’s the banner I am adding to my template.
The Category Template Plugin in Action
Now that we have the plugin activated, and we’ve made a new category template, we will see options to choose the category templates 1.) when we create a new category, and 2.) when we edit existing categories.
Creating a New Category
The option to choose a template for your category appears at the bottom of the left-hand side when you create a new category. (Posts > Categories)
Editing Existing Categories
The option to choose a template also appears at the bottom of the page when you are editing an existing category.
And here’s the result of my banner template test.
(NOTE: These templates style only your category pages – e.g. mysite.com/category/music. They do not style the individual posts in the categories.)
Photo: Letterpress Blog from BigStock