function my_searchwp_exclude( $ids, $engine, $terms ) {
$entries_to_exclude = get_posts(
array(
'post_type' => 'product',
'nopaging' => true,
'fields' => 'ids',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'operator' => 'NOT EXISTS',
),
),
)
);
$ids = array_unique( array_merge( $ids, array_map( 'absint', $entries_to_exclude ) ) );
return $ids;
}
add_filter( 'searchwp_exclude', 'my_searchwp_exclude', 10, 3 );
#exclude #searchwp #uitslaluiten #WC #woocommerce #wp_query