Hi there!
Is is possible to exclude posts from a specific category from showing up as search results?
Thanks!
Hey worldfuturecouncil!
Please add the following to your functions.php file
function wcs_exclude_category_search( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( $query->is_search ) {
$query->set( 'cat', '-22, -21' );
}
}
add_action( 'pre_get_posts', 'wcs_exclude_category_search', 1 );
where you replace -22, -21 with the category IDs u need
Cheers!
Basilis