Exclude a WordPress Category from your RSS Feed

You have a WordPress blog and sometimes you just don’t want blog posts from certain categories to be displayed in your RSS feed. So what do you do? Here are a few ways to exclude a WordPress category from your RSS feed. They’re pretty simple to implement and they work.

Edit functions.php

One of the most simple and best ways to exclude certain categories from your RSS feed is by adding this small function to your functions.php file in your WordPress theme directory. Simply open up functions.php and add the following function to it. In the below example we are excluding category 1 and category 5.

function rssFeedExcluder($query) {
 if ($query->is_feed) {
   $query->set('cat','-1,-5');
 }
return $query;
}

add_filter('pre_get_posts','rssFeedExcluder');

You can exclude multiple categories by separating them with a comma.

Change the RSS Feed URL

Another very easy way to exclude categories from your RSS feed is by simply changing the URL of your WordPress RSS feed. All you need to do is add a query string to the end of your RSS feed URL with the categories you want to exclude. In the below example we are excluding category 1 and category 5 from our RSS feed. The URL of our RSS feed is “www.yourwebsite.com/feed”.

www.yourwebsite.com/feed?cat=-1&cat=-5

If you’re using FeedBurner you can use this URL in your FeedBurner account settings. Simply click on “Edit feed details” from your dashboard and add the new URL.

Use a Plugin

If you’re not good at coding you can simply add the Ultimate Category Excluder plugin to your WordPress site to exclude categories from your RSS feeds. Simply download the plugin, add it to your plugins folder, activate it in your WordPress admin panel and add the categories you want to exclude from your feed. That’s it! I’m not really a fan of adding plugins unless you really need them as having too many plugins can make your website a lot heavier than it needs to be.

Adham Dannaway

Web Designer and Front End Developer with a passion for web design, coding, blogging, WordPress and chewing gum. Check out my web design portfolio and follow me on Twitter and Facebook!

Share this post!

Tags: , , , , , , ,

  • Share
  • Stumbleupon Cre8ive Commando
    • Share

  1. Max D on May 26, 2011

    Thank you for writing this article. I greatly enjoyed it. I work in web design too. Keep up the excellent work!

Trackbacks


Have your say!