• About Us
    • New York
  • Work
  • Capabilities
  • Careers
  • Technology
  • Blog
  • Contact Us
  • About Us
    • New York
  • Work
  • Capabilities
  • Careers
  • Technology
  • Blog
  • Contact Us
July 22, 2011

Three Ways to Make Your WordPress Category Pages Better

Posted by Christopher Davis

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.

1. Add Unique Content

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.

taxonomy description input

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(); ?>
1
2
3
4
5
<?phpif(have_posts()):?>
<div class=“post clear”>
    <h1><?phpsingle_cat_title();?></h1>
        
    <?phpechocategory_description();?>

2. List Subcategories

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.

1
2
3
4
5
6
7
8
<h2>Subcategoriesof<?phpsingle_cat_title();?></h2>
<?php
wp_list_categories(
    array(
        ‘child_of’=>get_queried_object_id()
    )
);
?>

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; ?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$cats=get_categories(array(‘child_of’=>get_queried_object_id()));
if(!empty($cats)):
?>
<h2>Subcategoriesof<?phpsingle_cat_title();?></h2>
<ul>
    <?php
    foreach($catsas$cat)
    {
        echo‘<li><a href=”‘.get_category_link($cat->term_id).‘”>’.esc_attr($cat->name).‘</a></li>’;
    }
    ?>
</ul>
<?phpendif;?>

3. Add Images

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

1
2
3
4
5
add_action(‘after_setup_theme’,‘pmg_add_thumbs’);
functionpmg_add_thumbs()
{
    add_theme_support(‘post-thumbnails’);
}

Then, somewhere in the loop, you can call the_post_thumbnail to display the image.

wordpresswordpress category page
Next

Latest White Papers

  • Shifting Plans for 2020 & Beyond
  • Game On: How Brands Can Log Into A Diverse Multi-Billion Dollar Industry
  • What CCPA Means For Brands
  • How Google is Improving Consumer Data Privacy
  • Ways to Prepare for the Cookieless Future
  • See all White Papers

Featured Posts

  • Ad Age Names PMG #1 Best Place to Work in 2021
  • Hindsight 2020 & Looking Ahead to 2021
  • Preparing for Streaming’s Growth & The Future of TV Buying
  • MediaPost Names PMG Independent Agency of the Year
  • PMG Client Portfolio Trends During Amazon Prime Day 2020

Categories

  • Consumer Insights
  • Content
  • Creative Design
  • Data Analytics
  • Development
  • Digital TV & Video
  • Ecommerce
  • Industry News
  • Local
  • Mobile
  • Paid Search
  • PMG Culture
  • Programmatic & Display
  • SEO
  • Social Media
  • Structured Data
Fort Worth

2845 West 7th Street
Fort Worth, TX 76107

Dallas

3102 Oak Lawn Avenue
Suite 650
Dallas, TX 75219

Austin

823 Congress Avenue
Suite 800
Austin, TX 78701

London

33 Broadwick Street
London
W1F 0DQ

New York

120 East 23rd Street
New York, NY 10010

Get in touch

(817) 420 9970
info@pmg.com

Subscribe to the PMG Newsletter
© 2021 PMG Worldwide, LLC, All Rights Reserved
  • Contact
  • Privacy Policy
 Tweet
 Share
 Tweet
 Share
 Tweet
 Share
 LinkedIn
We and our partners use cookies to personalize content, analyze traffic, and deliver ads. By using our website, you agree to the use of cookies as described in our Cookie Policy.