Leave a category out of the RSS feed
Posts in the category you choose don’t appear in your main RSS feed. Good for announcements or members-only posts.
Before you switch it on: Replace 123 with the category’s ID (hover over it in Posts > Categories, or turn on “Show IDs in the admin lists”).
It arrives switched off, even when you install its whole pack with "Switch on after installing".
<?php
add_action(
'pre_get_posts',
static function ( $query ) {
if ( $query->is_main_query() && $query->is_feed() && ! $query->is_category() ) {
$query->set( 'category__not_in', array( 123 ) ); // The category's ID.
}
}
);
In these packs
- RSS feeds: Control what your RSS feed shows, and when.