WordPress based Blogs and Magazines usually have their articles sorted into several categories. In some cases, it would be a good idea to create a visual difference between the categories. It would specially be the case when category topics or article types are different for each category. Custom WordPress categories would improve the visitors user experience and visually enhance any blog or magazine. In this tutorial we’ll show you how to create a WordPress custom category page for each blog category.
What are the possibilities of a WordPress custom category page
The possibilities of a WordPress custom category page are limited only by your imagination and your programming skills. Each custom category may have it’s own visual appearance, content layout and special functions. Various modifications of the default WordPress category template are possible, such as:
- different custom title for each category
- different header, footer and sidebar for each category
- different layouts of the posts loop
- different layouts of the articles in the posts loop
- category specific additional content before or after the post loop
- category specific color palette
- etc.
Creating visually different category pages is a good idea for blogs or magazines with several categories covering different topics.
WordPress Categories Hierarchy
To create a WordPress custom category page, firstly we have to understand how are category pages generated. WordPress Categories Hierarchy defines which category template file will generate the Category page. The template order defined by the Hierarchy is the following:
- Archive template file: archive.php
- General category template file: category.php
- ID-number defined custom category: category-id.php
- Slug defined custom category: category-slug.php
According to the Categories Hierarchy, WordPress will first look for the custom category template file defined by slug, for example category-summer.php. In case there’s no slug defined custom category template, the system will look for a id number defined category template, for example category-10.php. If there are no custom category template files, WordPress will fallback to the default category page template category.php. Finally, if no category template files are present, WordPress category page will be generated from the archive.php file.
How to create a WordPress custom category page
Assuming you already defined the post categories for your blog, its time to create some custom category template files. Firstly you have to check which template file generates your default category page. Look for the category.php file in your theme’s files list. In case there’s no such file, you will find archive.php instead. Some WordPress themes have both files in the list, some have only archive.php.
Now that you know which template file generates your default Category page, you need to duplicate the file and rename it according to the WordPress Categories Hierarchy. In our example, we’ll duplicate our archive.php. Let’s say we have a post category named “Summer Vacations” with the corresponding slug “summer-vacations”. We’ll rename our duplicated archive.php to category-summer-vacations.php. Repeat this step for each blog category you want to customize.
Pro Tip: To duplicate and rename WordPress theme files, you can use a FTP client, or your hosting cPanel File manager. A even easier and faster way of doing it is by using a WordPress File Manager. Check out our review of the most popular WordPress File Manager Plugins.
Following the WordPress folder structure, you will find the category template files following the path: public_html/wp-content/themes/your_theme/. If your WordPress installation has its own folder, the path might look like public_html/wordpress/wp-content/themes/your_theme/. Slight differences are possible from site to site.
Customize the WordPress category page
As we described above, there are plenty of possibilities for customizing a WordPress category page. There are simple tweaks to start from, such as customizing category titles or changing the color palette. Those tweaks require only basic HTML and CSS knowledge. More advanced developers could go for a different header or footer, or even customize the layout of the articles in the post loop. The customizing possibilities are too many to cover with one tutorial. We’ll cover more customization options in our further tutorials.
To learn more about customizing your WordPress category page, you can start from here: