Age of Article Warning:
This article was originally published 47 months ago. The tips and techniques explained may be outdated, or information may longer be applicable. Please consider this when viewing the below content.

One of the great things about WordPress is that it is an excellent tool for blogging. If you visit your blog page, you’ll see that, the WordPress Loop will automatically list recent posts from all your categories.

However sometimes you might not want a certain category to show up in the list of posts. This is where the “pre_get_posts” action is so useful. Perhaps you are using a particular category of posts for your image slider, and so you don’t want them to show up in the main page. Simply add the following code into your childtheme’s function.php file and replace with the IDs for the category you want to hide.

Note: This will hide that category from both your blog page and also from your RSS feed. (replace ’13’ with your category ID)

[php]
/** Remove category from feed and blog page */
function dtwd_exclude_category($query) {
if ( $query->is_feed || $query->is_home ) {
$query->set(‘category__not_in’, ’13’ );
}
return $query;
}
add_filter(‘pre_get_posts’, ‘dtwd_exclude_category’);
[/php]

How to Remove a Category from rss blog feed was last modified: February 12th, 2013 by David Tiong
How to Remove a Category from rss blog feed