How to Exclude Specific Categories from WordPress RSS Feed270

7How-to-Exclude-Specific-Categories-from-WordPress-RSS-Feed
Author: InfoBeep - November 30, 2017 | subject to copyright

Some of site owners don’t want some of the categories to appear in RSS feed. If you are one of them, we have this article especially made for you. We have listed 2 different methods with steps to do this.

Method 1: Exclude specific categories from WordPress RSS feed using plugin

In this method, we will guide you to exclude specific categories from WordPress RSS feed using plugin. You may follow the steps below:

  • Install as well as activate ‘Ultimate Category Excluder’ plugin.
  • After activated, go to Setting > Category Exclusion. Now, simply tick the category you want to exclude from RSS feed.

ULtimate-category

  • Click on update button after you are done.

Method 2: Manually exclude specific categories from WordPress RSS feed

In this method, you need to copy the code given below in your theme’s functions.php file or a site-specific plugin.

function exclude_category($query) {

    if ( $query->is_feed ) {

        $query->set('cat', '-5, -2, -3');

    }

return $query;

}

add_filter('pre_get_posts', 'exclude_category');

(note: in the code above, we have excluded categories 5, 2 and 3. You may have different category. Replace your category with the random categories given.)