How to Create WordPress Category RSS Feeds

WordPress RSS Shop

Here’s a fun fact I bet you didn’t know: WordPress provides built-in feeds for every category, tag, comment, post, author, and even search result.

The problem is, how do WordPress users know where the feeds are and how to utilize them? Well, unless your theme already has this setup, you really don’t. This tutorial will show you how to dynamically create and display WordPress category-specific feed icons.

Why are category-specific feeds important?

Some people aren’t interested in a general rss feed. They want to follow a specific category. For example, our new Marketplace includes several different categories (i.e. Child Themes, Plugins, Payment Gateways, etc).

If you’re interested in all new items, you can subscribe to the general rss feed. On the other hand, say you only care about new payment gateways and don’t want your AppThemes rss feed cluttered up with new child theme items.

Step 1 – Add one cup code

Edit your category.php theme file and paste in the following code somewhere towards the top. This will display the feed link. If you don’t have category.php, you’ll either need to create it (advanced users) or edit your archive.php template which is the fall thru template.

<?php
if ( is_category() ) {
  // retrieve current category object
  $category = get_category( get_query_var('cat') );
  if ( ! empty( $category ) )
    echo '<div class="category-feed"><a href="' . get_category_feed_link( $category->cat_ID ) . '" title="' . sprintf( __( 'Subscribe to the &quot;%1$s&quot; category', 'appthemes' ), $category->name ) . '" rel="nofollow">Subscribe!</a></div>';
}
?>

You’ll notice we did a couple of things. First, get the current category object. Then grab the feed link using get_category_feed_link(). We also added a title tag which is useful when hovering over an icon (instead of using text) and a rel="nofollow" so we don’t leak SEO juice.

Note: We wrapped an extra if is_category() check around the code so it would work in archive.php.

Step 2 – Test it out

Visit any of your category pages and you should see a “Subscribe!” link. If you hover over the link, you’ll notice it’s unique for the category. Great! You’ve got it working now. Next, we need to pretty it up.

Step 3 – Put on some makeup

We wrapped the link with a div so it’s easy to style the link. If you want to use just an icon instead of the text link like we did, you can do that too. Just remove the “Subscribe!” text from the code and include an rss icon in the css. You will paste this in your theme’s style.css file. Here’s what we used:

.category-desc { 
    margin-bottom:10px; 
}
.category-feed a { 
    float:right; 
    width:16px; 
    height:16px; 
    background:url('images/rss-icon.png') no-repeat left 0 transparent; 
}
.category-feed a:hover { 
    opacity:0.7; 
}

You’ll likely need to make some tweaks before it’s perfect but that’s pretty much it!

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

Your rating: none
Rating: 3.3 - 10 votes

Written by: on September 6, 2012. Last modified: September 7, 2012

Popular Marketplace Items

  • pcp-featured
    $39

    Price Comparer

     (3)
    Jump start your Price Comparision site with products from Amazon, Commission Junction, and LinkShare.
  • GeoReg thumbnail
    $29

    GeoReg

     (10)
    Captures detailed geographic info with new user registrations.
  • 2Checkout Payment Gateway Plugin
    $39

    2Checkout

     (4)
    Accept up to eight payment methods, fifteen languages, & twenty six currencies.
  • critic-icon-2
    $39

    Critic

     (7)
    A professional review and rating system for WordPress.
  • adposter-blocker-thumbnail
    $9

    AdPoster Blocker

     (2)
    A simple but powerful plugin that blocks spammy new user regs and/or ads/jobs/posts.
  • wp-smart-export-final
    $25

    WP Smart Export

     (3)
    A highly customizable WordPress data exporter plugin.
  • Authorize.Net Thumbnail
    $39

    Authorize.Net

     (3)
    Easily start accepting online payments via credit card and e-check.
  • stripe-plugin
    $39

    Stripe

     (4)
    Process credit cards safely and securely on your AppThemes website.
  • daddy-likes-190x130
    $19

    Daddy Like

     (10)
    A fast, lightweight, and elegant "like" system for comments, pages, posts, & activities.
  • marine-marketplace-thumb
    $39

    Marine

     (1)
    A clean, modernĀ and fully responsive marine-based goods WooCommerce Theme.
  • autoauto-thumbnail
    $39

    AutoResponder AutoRegistration

     (4)
    Automatically integrates WordPress registration with major autoresponders.
  • featured
    $9

    QR Codes Widget

     (3)
    Add a widget with QR codes to your AppThemes site.
  • screenshot
    $39

    Convert

     (2)
    A conversion focused responsive Clipper child theme with premium features.
  • balanced-payments-plugin-sm
    $39

    Balanced Payments

     (3)
    Accept credit cards and setup escrow payments.
  • StarStruck WordPress Plugin Thumbnail
    $19

    StarStruck

     (16)
    A fast, lightweight, and elegant star rating system for comments, pages, & posts.
  • AppThemes Coupon Plugin
    $29

    AppThemes Coupons

     (8)
    An easy way to start offering coupons and promotions to your customers.