Home › Forums › WoodMart support forum › Empty search results › Reply To: Empty search results
June 13, 2023 at 12:39 pm
#474570
kuba
Participant
Regarding the search results I found the code snippet that prevents it from displaing, it’s needed as I don’t want to show items from selected categories in main catalog. So how to fix that?
The product aromabar is in this exclusion so this is probably the reason it shows empty.
Also in the search results preview there is no label on products out of stock.
Also it doesn’t fix the compare and wishlist
// Exclude category from shop archive
add_action( 'pre_get_posts', function( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( function_exists( 'is_product_taxonomy' ) && is_product_taxonomy() ) {
return;
}
$tax_query = (array) $query->get( 'tax_query' );
$tax_query[] = [
'taxonomy' => 'product_cat',
'field' => 'slug',
'operator' => 'NOT IN',
'terms' => [ 'wydarzenia', 'deli', 'akcesoria' ],
];
$query->set( 'tax_query', $tax_query );
} );