Hello,
>to use the Show Categories dropdown, but have it limited to Used and New
There is a modification for it:
Limit categories in the drop-down
http://hottons.com/ymm_modifications_other
ALTERNATIVE 1: ————————————————————–
Try to replace this code:
if (!is_product_category() || count($values) > 0){//filter category page only when values selected
$wp_query->query_vars['post__in'] = count($pIds) > 0 ? $pIds : array(-1); // -1 to display a "no products found" message
}
with:
if (!is_product_category() || count($values) > 0){//filter category page only when values selected
$wp_query->query_vars['post__in'] = count($pIds) > 0 ? $pIds : array(-1); // -1 to display a "no products found" message
$wp_query->query_vars['tax_query'] = array( array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'courses' ),
'operator' => 'NOT IN'
));
}
in the file:
wp-content/plugins/ymm-search/Controller/Product.php
Replace ‘courses’ with the slug of your category.
I have found it here:
https://www.businessbloomer.com/woocommerce-exclude-category-from-search/
ALTERNATIVE 2 (I have not checked it) ————————————–
To exclude wordpress category:
function SearchFilter($query) {
if ($query->is_search) {
$query->set('cat','-5');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
Replace -5 with the number ID of your category.
https://cullenwebservices.com/exclude-category-from-wordpress-search/
Stanislav
Thanks for this. It might work my client. It would be better if it was per filter (via the shortcode or something) as opposed to globally)
