I'm trying to exclude WooCommerce products from default WP search, but I need to keep all other posts types, including CPT and those CPT created in the future. Im trying with:
function searchFilter($query) {
if (!$query->is_admin && $query->is_search) {
$query->set('post_type', array('post', 'page', 'CPT'));
}
return $query;
}
add_filter('pre_get_posts', 'searchFilter');
In code above I can set in post_type
what posts types I want to choose. But I would like to exclude only a 'products' post_type. Is there any way to create parameter like that?