excluded category from main shop – search problem
-
Hi,
I used this code on my child’s functions.php to prevent a specific category to appear on the main shop.
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' ); function custom_pre_get_posts_query( $q ) { if ( ! $q->is_main_query() ) return; if ( ! $q->is_post_type_archive() ) return; if ( ! is_admin() && is_shop() ) { $q->set( 'tax_query', array(array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( '110-vinilocuero' ), // Don't display products in the "110-vinilocuero" category on the shop page 'operator' => 'NOT IN' ))); } remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' ); }
But now I realized those products in this category are restricted form the search function.
…So I was wondering if they can be included in the search.
I am using storefront and woocommerce latest versions.
Thanks in advance.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘excluded category from main shop – search problem’ is closed to new replies.