Creating Category Specific Template Pages

Are your category pages a little bland? Want to add some tutorials to your cooking category? Maybe your photography category should have more photography on it? If you want to customize individual categories or tags, you’ve come to the right place.

In Vantage, and across many of AppThemes Products as well as WordPress Themes in general, categories are very important. They organize posts, listings, etc into different groups that let your users find the content they are looking for quickly. But, different categories can be different. They require specific layouts and sometimes unique content. Because each category might have its own needs, WordPress let’s us treat them differently using templates.

A template is a WordPress file that controls how a certain page works. Your home page is controlled by a template, and so are the rest of the pages on every WordPress site. They tell WordPress how the page should look (branding, layout, etc) and where to put the content. In WordPress, there are many different templates you can create. This post will deal with taxonomy specific templates that let you create a template page for designated categories.

Taxonomies

WordPress uses taxonomies. What are taxonomies? A taxonomy is a way of grouping things. For instance, you could make a list of all your relatives, and group them by their last name, the city they live in, or the number of people in their immediate family. Each of these groupings are a taxonomy.

In Vantage and in WordPress, we have two primary taxonomies: categories and tags. You can give a listing one category and any number of tags you’d like. You can put a listing under the ‘automotive’ category, ‘shopping’ or ‘restaurant’. A term is any word used to group things in a taxonomy. In this case, the terms in our category taxonomy would be ‘automotive’, ‘shopping’, and ‘restaurant’.

Each of these terms has their own page so that users can find all the listings in the ‘automotive’ category in one place. We can changes these pages based on the term being used. For instance, we can create a page for the automotive category, which will show up whenever you want to list all of the listings in the automotive category.

Creating a Taxonomy Specific Template Page

To create a template page for one of these terms, all you have to do is create a file with a specific name. WordPress will handle the rest. To name the file, use this simple formula:

taxonomoy-{taxonomy_name}-{term_name}.php

For instance, a file named taxonomy-listing_category-software.php will show up whenever I go to example.com/category/software/.

What you put in this template file is up to you. You can learn all about template files and how they work on the WordPress codex. If you’re using an AppThemes product, you’ll probably want to copy an existing file, like archive-listing.php for Vantage, and make tweaks where you need to. And remember, always use a child theme.

Wrapping

In most WordPress themes, you need to call get_header() and get_footer() to get other parts of the template. With AppThemes Products, these functions will be called before and after your template. See our article on Wrapper.php for more information.

Like this tutorial? Subscribe and get the latest tutorials delivered straight to your inbox or feed reader.

Your rating: none
Rating: 5 - 3 votes

Popular Add-ons

Mapsupreme for Vantage

A plugin that adds additional Google Maps to your Vantage theme.


(28)
$29

Fortumo SMS payment gateway

Fortumo sms payment gateway for ClassiPress


(3)
$39

Sorted Filtered Coupons

Sorting and Filtered Coupons on coupons listing pages as well as search…


(3)
$19