How To Exclude Specific Categories from RSS Feed - WPTRINITY

How To Exclude Specific Categories from RSS Feed

When you want to exclude specific categories from your WordPress RSS feed? Add this code to your theme’s functions file.

function exclude_category($query) {
    if ( $query->is_feed ) {
        $query->set('cat', '-5, -2, -3');
    }
return $query;
}
add_filter('pre_get_posts', 'exclude_category')