open core »

Feedsmith plugin hack to allow feeds by tag and category

If you use Feedsmith (the Feedburner plugin for Wordpress) you have probably noticed that it redirects all the feeds in your wordpress blog to your feed in Feedburner. This is very handy, except if you want to have feeds of posts filtered by tag and/or by category. The URL for such a feed is something like this:

This URL will show you a feed of all posts tagged with "linux".

It happens that if you have the Feedsmith plugin activated, the URL shown will redirect to the global feed in Feedburner. If we want to change that behavior we need to get our hands in the dirt and hack the plugin's PHP code.

To do this, just find the plugin's PHP file. By default its located in /wp-content/plugins/. Edit the file using any editor with ftp client or whatever you wish. Find the function named ol_feed_redirect() and change the following code:

<?php if (is_feed() && $feed != 'comments-rss2' && !is_single() &&

To the code below, by adding !is_tag() && at the end of the above line:

<?php if (is_feed() && $feed != 'comments-rss2' && !is_single() && !is_tag() &&

Or, if you wish to filter categories:

<?php if (is_feed() && $feed != 'comments-rss2' && !is_single() && !is_category() &&

If you want both, just add one after another.

Now we need to make available the link to these new feeds, since they won't be in Feedburner. Just place somewhere in the blog the links like this: