Filter for Excluding Certain Categories in WordPress

Put this code in the Functions.php file:

// filter for exluding certain categories
function myFeedExcluder($query) {
if ($query->is_feed) {
$query->set('cat','-12');
}
return $query;
}

add_filter('pre_get_posts','myFeedExcluder');

This will exclude category 12 from your RSS feeds. If you want to exclude more than one category, put them in separated by commas ‘-12,-25,-33′.

Related posts:

  1. Modifying Archive Pages in WordPress
  2. Making WordPress Sub Categories Use Parent Category Template
  3. WordPress Archive by Category
  4. WordPress Query_Posts and Pagination
  5. Reorder Categories in WordPress

Leave a Comment

Let us know your thoughts on this post but remember to place nicely folks!