how you can easily disable category feeds (and tag feeds) in wordpress websites

Wordpress is one of the common and popular content management used to develop and publish Blogs and websites. Wordpress provides RSS or news feed support out of the box without a very good interface to either enable and/or disable any or all of those feeds.

If you use Google Feedburner, then it is quite cumbersome to create a feed for each and every category and tag. I tend to create quite bit of tags for each of the blog posts but only a small number of category. It could be different in your case. Moreover, tags are created mostly on the fly when I post than categories are. This makes it quite difficult to create a new feed in Feedburner every time I post and create a new tag.

So, I wanted to disable just the tag feeds but keeping the category and website feeds intact. This, as I found was quite difficult as tags and categories are quite inter-twined in WordPress. Disabling both is quite easy but disabling just one or the other needed a little more work.

Having said that it is not that difficult if you are quite a bit handy with some level of programming. First locate the functions.php file in your theme folder or where ever you define your custom functions. Open this file in text editor and include any of the following code in it.

Disable both category and tag feeds

For some reason, both the category and tag feeds call the same filter from within the core files (at least as of version 3.2.1). I think it is probably going to change in a future release. Till then, if you can use the following code to disable both the tag and category feeds.

function disable_category_tag_feed () {
return;
}
add_filter('category_feed_link', 'disable_category_tag_feed');

Disable Category Feed

If you like to remove or disable category feed, but would like to keep the tag feeds, then use this code below. Before you do that, find the category slug that you use on your blog. It is the word that you use to identify the category pages on your blog. You can find this by referring to the Dashboard -> Settings -> Permalinks page on your Wordpress Dashboard. For example I use topics as my slug for categories. Now replace the slug that you use in the following code to disable the category feed.

function disable_category_feed () {
if (strrpos($link, '/topics/') > 0)
return;
else
return $link;
}
add_filter('category_feed_link', 'disable_category_feed');

If you are having a hard time finding your category or tag slug refer to the following screenshot

wordpress-dashboard.png

Disable tag feed

If you prefer to disable the tag feed, but like to keep the category feeds, then find your slug that you use for tags in your blog. I use tags as my slug for the tag pages. Again, you can find this in your dashboard under Dashboard -> Settings -> Permalinks. Replace the tag slug that you use in the following code to remove your tag feeds.

function disable_tag_feed () {
if (strrpos($link, '/tags/') > 0)
return;
else
return $link;
}
add_filter('category_feed_link', 'disable_tag_feed');

All of the above code were tested with Wordpress version 3.2.1. It is quite possible that future version may change and these maynot work correctly. So, check your wordpress version before modifying. Check out on how to disable comments, author or search results feed in wordpress.