Hello there,
we hope you’re doing well!
In order to exclude certain product categories for the wishlist, add this code in the functions.php file of your active theme:
if ( ! function_exists( 'yith_wcwl_show_add_to_wishlist_button_exclude_categories' ) ) {
function yith_wcwl_show_add_to_wishlist_button_exclude_categories( $show ) {
global $product;
$excluded_categories = array(
'category-1',
'category-2',
);
$product_categories = wp_get_post_terms( $product->get_id(), 'product_cat' );
$product_categories = $product_categories ? wp_list_pluck( $product_categories, 'slug' ) : array();
if ( array_intersect( $excluded_categories, $product_categories ) ) {
return false;
}
return $show;
}
add_filter( 'yith_wcwl_show_add_to_wishlist', 'yith_wcwl_show_add_to_wishlist_button_exclude_categories', 10, 1 );
}
And for exclude some products:
if ( ! function_exists( 'yith_wcwl_show_add_to_wishlist_button_exclude_products' ) ) {
function yith_wcwl_show_add_to_wishlist_button_exclude_products( $show ) {
global $product;
$product_id = $product->get_id();
$excluded_products_id = array(
'id-1',
'id-2',
);
if ( in_array( $product_id, $excluded_products_id ) ) {
return false;
}
return $show;
}
add_filter( 'yith_wcwl_show_add_to_wishlist', 'yith_wcwl_show_add_to_wishlist_button_exclude_products', 10, 1 );
}
You can add the number of categories/products you want.
Try it out and tell us if it works well for you.
We will be attentive to your response.
Have a nice day!