WordPress automatically displays blog posts in the category pages in an reversed chronological order. But do you know where the design comes from?
It comes from your WordPress theme. That is why you notice the design changes when you change your theme. All themes have a design for category pages. However, almost all of the themes offer a basic design for all archive pages. But what if you want to customize it?
Few themes offer limited customization options. But, you need a create a custom template if you really want to personalize it based on your website’s branding. How?
That’s what we will explore today. In this blog post, you will learn all about category page templates, and how to create a custom one with or without a plugin.
What is a WordPress Category Page Template
A category page template refers to a predefined design of how the posts will be displayed on the category pages. To be specific, how the category title, descriptions, posts, and post metadata will be displayed, depends on how the template is coded or designed.
Most of the WordPress themes don’t offer a specific template for categories. They usually come with Archive page templates that cover all archive pages including categories, tags, author, etc pages.
But if you want, you can create and use specific templates for specific types of archive pages. Not only that, but you can also use a template for a particular category, tag, author, or whatever archive you want.
Before start creating a custom template we should know about the Hierarchy of the category template.
WordPress has a pre-defined templating system for Archive pages including categories. When we visit a particular category page, WordPress looks for a template. If one kind of template is not present it looks for the next possible template and it goes on.
Here is the order of templates WordPress looks for:
category-slug.php → category-id.php → category.php → archive.php → index.php
So, If we want to create a Template for all category pages we have to name it category.php. And, for specific Templates for categories, we have to name them category-slug.php or category-id.php.
Examples: Category-entertainment.php, Category-7.php.
Note: Slug must be replaced with the name of the category for which we are making the template. While using category-id.php we have to add the category ID number by replacing the id.
You can learn more about the WordPress template higherchy from the official documentation.
Why Create a Custom Category Page Template in WordPress
Before going into the in-depth discussions, I would like to discuss the importance of creating custom templates for category pages. I guess you will want to create one for any or all of the following reasons. If not, make sure to share your reasons in the comment section.
Better Content Presentations: The most common and obvious reason for changing the category page layouts is to showcase blog posts in a better way. So the readers can easily navigate the contents.
On-Page SEO Optimization: You would also want to make a custom layout to enhance the SEO optimization. For example, you might want to add long-form content to rank for specific keywords. However, WordPress displays the content before showcasing the blog posts that are reader-friendly. A custom template allows you to add the content after the blog posts. So the readers can read the content if they are interested. Otherwise, they can just explore the blog post they are interested in.
Enhanced Branding: Using the default layouts of your theme is okay for a certain period. But once your website or blog starts growing, you focus on the branding. For that, you need to have custom designs across your website. It gives a unique brand identy to your blog or website.
Better Audience Engagements: A properly optimized layout for category pages helps increase the reader’s engagement. So, if your current theme doesn’t have an ideal layout, you should create a custom one.
Prerequisite to Create a Custom Template for Category Pages
WordPress doesn’t have any template created by default. But don’t worry, there multiple ways by which you can create a custom one. I will discuss three 3 popular ways to create a custom template for category page pages. But before going into that, let’s explore the prerequisite.
Builder Plugin
The most common and effective way to create a custom template is using a Builder. It can be any WordPress plugin, like Elementor, Divi, or Beaver Builder. However, if you have a blogging website, then We will recommend you to use PostX. It is an all-in-one solution for creating and improving visually appealing and growing WordPress blog sites. It has a Gutenberg-based builder and numerous templates for all dynamic and static pages.
Block Theme
You can also prefer using a theme instead of a plugin. In that case, you can go for the Twenty Twenty-Four theme by WordPress. It also has a Gutenberg builder named as editor. The editor allows you to create templates and template parts.
Custom Code
If you have some basic coding knowledge you can also use it instead of any plugin or a block theme. However, creating templates with custom codes would be time-consuming if you want to do too many things compared to the default template.
Fortunately, this is the generation of AI, so you can get custom codes based on your requirements. Then you just need to place the right codes in the right place.
So without further ado, let’s start creating our personalized templates. I am going to explain all three different methods. Explore all of them and choose the one that suits you best.
Method 1: How to Create a Custom Category Page Template Using PostX
Let’s start with the most easiest and advanced option, which is using a plugin. For the tutorial purpose, I am using PostX. So make sure you have installed the PostX plugin while following the steps.
Step 1: Enable the Builder Addon
At first, you need to make sure the Builder addon of PostX is turned on. You can find it in the Getting Started section of PostX.
Step 2: Start Creating a Custom Template
Once the builder is enabled, go to the builder section. Here you can see custom template creation options for all essential pages. For now, I am choosing the Category option, as we want to create the template for category pages.
Step 3: Choose a Premade Template
Now, you can see various premade designs. So either you can choose one of them or start from scratch. For now, let’s choose a premade option. Explore them and click on the import button of your preferred design.
Step 4: Choose Desired Condition
Then you need to select a condition for the template. It means for which archive pages you want to use a template. For now, let’s select all categories, as we want to use one template for all category pages. However, you can also create a template for a specific category or any other archive page as well.
Step 5: Customize the Template
All of the PostX templates are ready to use. However, you can also make changes if required. The templates are built with different Gutenberg blocks with the required customization options. So you can customize each element independently.
You can click on any of the blocks to see its customization options. Then you can make your desired changes.
Step 6: Change the Category Template
You may not like it after importing a template. Don’t worry you can also change it without going back. To change the category template, mark all elements using CTRL + A, and remove them with Backspace.
Then, click on the builder library, explore, and choose your desired template. Then click on the import button.
Once, you are satisfied with the customization, click on the publish button. That’s all, your own personalized template for category pages is created and applied.
Method 2: How to Create a Custom Category Page Template Using Default Block Theme
If you have just installed WordPress, chances are you are still using the default block theme which is the Twenty Twenty-Four. It has a full site editor feature that allows you to create custom templates for all essential pages.
As it is the default WordPress theme, so you might want to keep using it. So let’s explore how we can create a custom template for category pages using the block theme.
Step 1: Start Creating a Custom Template
To create a template, you need to go to Appearance >> Editor. Then click on the Template option to explore all template-creating opportunities.
Here you can see that, no template is available for category pages. So we need to create a template for archiving all archive pages. For that, we need to click on the “All Archive” option.
Step 2: Customize and Publish
Here you can see that an archive template is already ready for us. We can use it, as it is or make our required changes before publishing. Unfortunately, the customization options are very limited. Let’s explore the available options.
In the template area, we have two options, Content and Design. From the content section, you can choose & edit the header and footer sections. In the design section, we have two different layouts to choose from.
However, we have more customization options for the query loop block including, column selection, text & background color, typography, and so on.
Finally, once we are satisfied with the customization, we need to click on the save button. And that’s all; there is nothing else we can do.
Method 3: How to Create a WordPress Category Page Template using Custom Code
Now comes the most important part of this tutorial blog post which is creating a custom template using custom codes. First of all, decide for which category you want to create the template and which file naming system you will use.
For instance, I want to create a custom template for the Entertainment category and I am going to use the 1st template format (category-slug.php). I am using the GeneratePress theme in which only has the Archive.php file.
Step 1: Log in to your cPanel
If you do not want to create a custom template from scratch, I have a simple solution for you. First of all login to the cPanel of your WordPress site.
Step 2: Go to File Manager
Now, you have to go to the File Manager from the cPanel dashboard.
Step 3: Locate and Download the Archive.PHP file
From the file manager, go to Wp-content → themes → current/active theme and download the Archive.php file.
Step 4: Change the filename
After downloading the file (default template). Change the name of the file.
As I am creating a custom template for the Entertainment category, I am changing the file name to category-entertainment.php. So, while visiting the Entertainment category the WordPress system displays the post according to the Category-entertainment.php template.
Step 5: Customize the Template
Now the Template is ready to upload. But, we have to make some changes according to our requirements. For instance, I would like to add some text and image content at the end of the template.
Step 6: Upload the Custom file to the Hosting cPanel
After making the necessary changes you can upload the custom template. Don’t forget to upload it to the correct file path otherwise, it will not work. The uploading path will be the same as Archive.php/Category.php: Wp-content → themes → current/active theme.
When I try to preview the Category page the alignment of the text and image is not matching the theme.
There are two ways to fix that one is writing custom CSS codes for the static content or using the existing CSS of the theme.
Now, the alignment should be the same as the theme as I have added CSS code.
Frequently Asked Questions
Where is the category template WordPress?
You can locate the WordPress Category template in two ways. Go to the theme editor and look for the category.php file.
If the file is not present look for the archive.php. You can also find the template from the cPanel of your hosting. Go to File Manager → WP-Content → themes → Current/Active theme and look for category.php/archive.php.
How do I customize a category in WordPress?
There are two ways to customize categories in WordPress. You can locate and edit the Category template from the cPanel and customize it by writing codes.
Or you can install the PostX plugin and use the Builder addon to create a custom template for specific or all category pages at once.
How do I style categories in WordPress?
The PostX Gutenberg Blocks Plugin has an exclusive Category Addon to style categories in WordPress.
By using the Addon you can set custom colors and images for all category pages. You can also use the Archive Builder addon to create custom templates and Taxonomy Blocks to showcase archives/categories.
How do I find the category hierarchy in WordPress?
Before finding the category hierarchy in WordPress you should know how it works. When we visit any of the category pages it looks for a specific category template, if the template is not present it looks for all category templates.
If all category template is not present it looks for the archive template. So the order/hierarchy of category template: category-slug.php → category-id.php → category.php → archive.php → index.php. You can find the template in the current/active theme folder of your WordPress site.
Which method is right for me to create a WordPress categories template?
We’ve shown three methods here. Both methods will work. However:
The method where you don’t use a plugin is not for novice users. There are certain risks associated with this method. For example, if you want to update your category page template, you need to download the file, make the changes using code, and upload it back again. This can potentially break the website structure (if not done correctly). And if you’ve never coded in your life, the method is likely to fail. It’s not a user-friendly method at all.
As for using a plugin, you can easily create an archive page with the PostX Gutenberg Builder plugin. It’s a lightweight plugin that’s beginner-friendly and doesn’t require any coding knowledge. It’s only a matter of a few clicks.
So, if you’re new to WordPress and want to do things right – going with a plugin is the best choice. Otherwise, you may end up making your website inaccessible.
Conclusion
That’s all about why and how to create a custom WordPress Category page template. If you still have any queries regarding this blog post feel free to comment below. We will be happy to guide you to create custom templates for the categories of your site.
Get PostX Pro to unlock all exciting features and make amazing Websites