Exclude category from blog page

Hi,

I want to exclude a post category from my blog page. I’m using Qode Bridge, in which the theme does not have this function by itself. So I’m trying to get this done with coding, but can not manage to get this working.

I want to exclude category #31, only on the page ‘blog’. How can I manage to do so?

function exclude_category( $query ) {
if ( $query->is_single ($post = 'blog' ) ) {
$query->set( 'cat', '-31' );
}
return $query;
}
 
add_filter( 'pre_get_posts', 'exclude_category' );

Thanks,

Neal

The page I need help with: [log in to see the link]



Source link