Below is the code to exclude posts of specific categories from WordPress RSS feed.
<?php | |
//* Exclude posts of specific categories from RSS feed | |
function customprefix_exclude_categories_rss_feed($query) { | |
if ($query->is_feed) { | |
$query->set('cat', '-5, -11, -18'); // Precede category IDs with a minus sign | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'customprefix_exclude_categories_rss_feed'); |