WordPress and FeedBurner FeedSmith: Getting to your category and tag feeds

Last time I touched on WordPress and Feedburner, the topic was how to tweak the Feedsmith plug-in so you could get access to your raw feed with Yahoo! Pipes. This time, I’m making some alterations to the plug-in so you gain access to your raw category and tag related feeds without those requests getting redirected back to your blog’s main Feedburner feed.

For most folks using the Feedburner redirect plug-in, getting access to WordPress’s category and tag feeds seems like a nightmare. I searched and searched myself, and all I found was numerous iterations of .htaccess file solutions. None of them worked for me, so I decided to go back to the Feedburner_FeedSmith_Plugin.php file and tool around. This turned out to be a quick fix, with one caveat – I don’t care to burn additional feeds for each of my categories, and this change won’t work for you if that’s your intention. In my case the blog categories are organized by “origin” of the post, not subject matter – what I really wanted was access to the tag feeds, which do relate to the subject of the post at hand. Here’s how to do it…

First, look to the bottom of the Feedsmith plug-in file (located under /wp-content/plugins/feedburner_feedsmith_plugin_2.2) for this:

if (!preg_match("/feedburner|feedvalidator/i", $_SERVER['HTTP_USER_AGENT'])) {
add_action('template_redirect', 'ol_feed_redirect');
add_action('init','ol_check_url');
}

That “!preg_match” bit tells WordPress to ignore redirect requests from Feedburner or FeedValidator so those services don’t wind up in an endless loop when trying to grab your raw feed. And it’s this same section of the plug-in code that pushes requests for category and tag feeds back to Feedburner for so many agitated users. We change that block of code to this (changes emphasized):

if (!preg_match("/feedburner|feedvalidator/i", $_SERVER['HTTP_USER_AGENT']) && !preg_match("/category|tag/i", $_SERVER['REQUEST_URI'])) {
add_action('template_redirect', 'ol_feed_redirect');
add_action('init','ol_check_url');
}

That additional “!preg_match” string tells WordPress to ignore redirects to Feedburner when the requested URL contains “category” or “tag”, but there is still one more thing you’ve got to do. In this blog’s case, my category base is “origin” – so in place of “category” I use the word “origin”; I still use “tag” for my tag base, so that stays the same. You set your category and tag bases in the WordPress admin panel under Settings..Permalinks – look for this:

wordpress-optional-permalink-controls

If your optional permalinks are set, change the code snippet above to reflect the same (/’s excluded) and save – otherwise set them as desired first then do the same. Now you should have raw category and tag feeds that work.

Two of the most popular tags on this blog are “Fly Fishing” and “Fannie Mae” – and here are their feeds:

  • Fly Fishing
  • Fannie Mae
  • Try it for yourself!

    Comments

    Josh says:

    Props, dude. Very helpful.

    Phil says:

    Does this still work with the latest versions of feedburner and wordpress?

    I’m running 2.7, and this stuff is still in place. You may have to tinker with it a bit if you are a new Feedburner subscriber, but I can’t be certain.

    Jason says:

    Excellent, thank you for this. So many workaround solutions I’ve found for this issue, but this is straight-forward, simple, and effective.

    No prob Jason. Glad it helped.

    Hi everybody,

    I followed the instructions, but so far without the result I hoped for. But more interestingly for me, when I want to subscribe to comment feeds on your posts, I get redirected to Feedburner. This is exactly what I’m tryng to a achieve on my blog but when I want to create a new feed in the Feedburner admin section, I always get a message saying:”We could not find a valid feed at that address”. I’m wondering how can you create a valid address as it would differ for each individual post? Chances are that I’m overlooking something essential here because I’m a newbie with regard to RSS.

    Any suggestions at all, but would be welcome.

    Bart

    Bart – There are several different circumstances at play here.

    First, the full comment stream on this site is burned already, so if you try and subscribe to all comments (http://michaelgracie.com/comments/feed/) you will indeed get redirected to Feedburner. I tested yours and it is working the same way. Individual post comment feeds are handled by the plugin – they don’t get redirected. Further, there is no reason to burn a feed for the comments on individual posts – you’d be burning new feeds constantly.

    This post in particular deals with the tag and category feeds, not comments. If you don’t add the extras above those feeds get redirected to the base. Have you appropriately labeled your category and tag base URLs first, and made the same changes to my suggested code?

    Hi Michael,

    I’ve been away on holiday for a few weeks, so that explains the lateness of my reaction. Thanks for your clarifying answer. I haven’t looked into the tag and category issue, but I will very soon.

    Kind regards

    Bart