Skip to content

Instantly share code, notes, and snippets.

@ashleyfae
Created January 11, 2016 20:27
Show Gist options
  • Save ashleyfae/9fc364cf86dc4100e10e to your computer and use it in GitHub Desktop.
Save ashleyfae/9fc364cf86dc4100e10e to your computer and use it in GitHub Desktop.
/**
* Exclude a specific category from your RSS feed.
*
* @param WP_Query $query
*
* @return WP_Query
*/
function exclude_category_from_rss( $query ) {
$cat_id = 0; // Change this to be the ID of the category you want to exclude, but put a - in front. Example: -99
if ( $query->is_feed ) {
$query->set( 'cat', $cat_id );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_from_rss' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment