How to exclude a specific category from blog posts in WordPress but if a blog post has two categories selected, one from excluded category and the other from included I would like to show the blog post.
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-7' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );
I tried using this function in function.php, it hides the excluded category but when two categories are selected for one blog post, it still hides