WordPress exclude category from blog

function exclude_category($query) { // exclude categories from the main blog with ID=15 and ID=25
	if ( $query->is_home() ) {
		$query->set('cat', '-15 -25');
	}
	return $query;
}
add_filter('pre_get_posts', 'exclude_category');

Source: How to Exclude a Category from a WordPress Blog or Page

Leave a Reply

Your email address will not be published. Required fields are marked *