2 MINUTE READ | July 22, 2011
Three Ways to Make Your WordPress Category Pages Better
Let me be honest with you: your WordPress category pages suck. It’s okay, it’s not your fault. Most theme designers don’t realize the value of a good category pages. Here are three ways to make yours better.
WordPress comes with a feature few theme developers make use of: the taxonomy description. It’s a short bit of text that describes your taxonomy (category, tag or custom taxonomy), and you can see the input for this thing on the “edit category” or “edit tag” page.
Call this into your category.php file with category_description. I like to stick this in right below the first heading tag.
<?php echo category_description(); ?>
<div class=“post clear”>
If you run a larger site with many subcategories, you should provide a way for your visitors to find their way around. Listing subcategories is one way to that.
So right below your category desciption, add some more code. First, we need to get a list of categories that are children of the current category. For this, we’ll use wp_list_categories.
This would work, except “Subcategories of [Some Category]” will always be on every category page regardless of whether it had subcategories or not. Instead, let’s change our code a bit to use get_categories, which will return an array. Once we have that, we can check to make sure we actually have categories before printing anything to the page. Then we loop through each category, getting the link with get_category_link. Note that get_categories returns an array of objects, so we already have the category name ($cat->name) and ID ($cat->term_id) for each category.
<?php endif; ?>
If you’re not using WordPress’ built in post thumbnails, you should be. From an SEO perspective, images add a valuable aspect to the page. So why not use them?
Enable post thumbnails in your theme by adding the following your your functions.php file
Stay in touch
Subscribe to our newsletter
Then, somewhere in the loop, you can call the_post_thumbnail to display the image.
AlliPMG CultureCampaigns & Client WorkCompany NewsDigital MarketingData & Technology
4 MINUTES READ | November 2, 2021
2 MINUTES READ | February 4, 2020