Transcript
All archives versus category template
In this lesson, we will explore adding and customizing a category template. In the previous lesson, we learned all about the various templates available. We mentioned that the All Archives template is the default template WordPress uses to display smaller groupings of posts, such as categories, tags, authors, dates, etc. Please note I am using the Twenty Twenty-Four default theme. Scrolling down will show how the All Archives template is currently structured and how posts within an archive will appear on the front end. When I visit one of my blog posts and click on the relevant category, in this case, Art, I can view all my posts labeled with the Art category.
The structure for this page has been dictated by the All Archives template. As mentioned, all other categories and groupings of archives will display in the same way due to the fact that they have been assigned to the All Archives template. This is where creating a custom category template comes into play. Instead of using the generic archive template, you can design one that suits your specific needs. Let’s see this in action.
Adding a category template
I will go ahead and add a category template to change the display of posts within the Art category. So, I will make my way to templates and click on the plus icon or the Inserter next to templates. Then, I will add a category archives template. Now you have two choices. Firstly, you can create a single template for all your categories. You may also decide to create a template for each specific category. I will select the second option as I want to create a specific template for the Art category. Once selected, I can choose a pattern that comes with the Twenty Twenty-Four theme. But I will go ahead and select Skip to start blank.
Customizing a category template
Now, I can start building my blank template. The first thing I will add is my new header – which I have already created and named Art Header. Once the unique header has been added to the template, I can click on the three vertical dots and select Add After. Next, we are going to add the Query Loop block. In this case, it will display all the Art posts. Now, we can go ahead and select a pattern for how we want the posts to display. And once the pattern has been added, we can modify it even further. So, let’s go ahead and open up the List view. Then, look at all the nested blocks within the Query Loop block. We are after the Post Template block. When we select the Post Template block, we will see three columns. We can change that to four. But in this example, we will settle for two columns.
Next, I want to delete my Post Excerpt block. So click on one of the posts, select the Post Excerpt block, click on the three vertical dots, scroll down to the bottom, and select Delete. Then, I will select the Group block and add more padding around the content. So I’ll open up my Styles, go to padding, and add more padding on the left and right. You are welcome to make further modifications, but for this example, I am done. So, the next step is to add a footer. I will also add the general footer that I’ve used on my other templates. Now, we can go ahead and see what our Art category will look like from the front end. So, if we select the relevant category now, namely Art, we will see the archives page for the Art category, with a unique header and modified content layout. This was, of course, achieved by adding and changing a category template for a specific item.
Conclusion
If you want to create a new template for a different category, you can click on the plus icon next to templates, select category archives, and then a category for a specific item. Then, I can create a unique template for my lifestyle or sports category. I trust you now feel comfortable adding a category template for all categories or a specific category.