Skip to content

Instantly share code, notes, and snippets.

@jpmarchand
Last active October 5, 2016 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmarchand/2b691cb2b6b8bdb07f1e to your computer and use it in GitHub Desktop.
Save jpmarchand/2b691cb2b6b8bdb07f1e to your computer and use it in GitHub Desktop.
Exclude posts of specific categories from WordPress RSS feed. Source: http://www.jangro.com/excluding-posts-from-your-blog-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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment