How to Add WordPress Category Feed Links to Posts
- Subscribing to Categories
- The Challenge
- The Code
- Try It for Yourself
I recently decided to change my blog’s RSS feed from summary to full text. But, at the same time, I was concerned that visitors wouldn’t subscribe to the feed because of the site’s unfocused nature—I cover so many topics that no one would be interested in everything I write about.
The solution, therefore, was to push category-specific feeds.
Rather than subscribing to the feed for my entire blog, visitors could subscribe to the feed for one or more blog categories—just the categories that interested them. Although some posts are tagged to multiple categories, thus resulting in occasional duplication among categories, subscribers would get only the content that interested them. Meanwhile, I could continue happily writing about whatever I liked, without fear of boring half my subscribers.
Subscribing to Categories
The ability to subscribe to individual categories is part of WordPress. My RSS page (see the tabs at the top of each page on my site) includes category links separated into my site’s two main sections: Maria’s WebLog and Book Support. This isn’t anything new. In fact, I wrote about how to create such pages in my April 2006 article "How to Create a WordPress RSS Feed Page."
Anyone can subscribe to a feed for a specific WordPress category on any WordPress blog—even if the links aren’t available on the site. All you need to know is the category number. The format is as follows:
http://domainname.com/blogfolder/?feed=rss2&cat=n
Substitute the actual domain name for domainname.com, include the blog folder if necessary, and replace n with the category number.
If custom permalinks are used, you need the complete path to the category folder. The format will be something like this:
http://domainname.com/category/maincategory/subcategory/feed
That’s the entire URL path followed by a slash (/) and the word feed.
The only drawback to subscribing to a category feed in this way is that the feed comes up with the same name as the blog, so if you subscribe to more than one category, the feed names appear the same. Since most feed readers enable you to customize a feed’s name for your own purposes, however, you can modify the feed names to distinguish between them. No big deal there.
Unfortunately, not everyone thinks of subscribing to individual blog categories, so I believe that this feature is highly underutilized. I wanted people to use it on my site, so I had to put it someplace they’d see and notice. In other words, I needed an "in your face" way to make it available.
But, of course, I didn’t want to make my site look trashy.