Exclude Categories from RSS Feed
Removes posts from specified categories from appearing in the site's RSS feed.
PHPby SnipCraft
php
<?php
// Add the numeric category IDs you want to exclude from the RSS feed.
add_filter( 'request', 'scseed_exclude_categories_from_rss' );
if ( ! function_exists( 'scseed_exclude_categories_from_rss' ) ) {
function scseed_exclude_categories_from_rss( $qv ) {
if ( ! isset( $qv['feed'] ) ) {
return $qv;
}
// Replace with the IDs of the categories to exclude.
$exclude_ids = apply_filters( 'scseed_rss_excluded_cat_ids', [] );
if ( ! empty( $exclude_ids ) ) {
$qv['category__not_in'] = array_map( 'absint', (array) $exclude_ids );
}
return $qv;
}
}#categories#content#feed#filtering#rss