Comments 3Steven started the conversationSeptember 18, 2020 at 8:22amHello. How can I force Salient's search facility to include ONLY WooCommerce products in the results? 3Steven repliedSeptember 18, 2020 at 10:08amI have solved this ticket by adding the below snippet to the functions.php file within the child theme. Please mark as closed. // Force search to only find productsfunction searchfilter($query) { if ($query->is_search && !is_admin() ) { $query->set('post_type',array('product')); } return $query;} add_filter('pre_get_posts','searchfilter'); Sign in to reply ...
Hello. How can I force Salient's search facility to include ONLY WooCommerce products in the results?
I have solved this ticket by adding the below snippet to the functions.php file within the child theme. Please mark as closed.
// Force search to only find products
function searchfilter($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('product'));
}
return $query;
}
add_filter('pre_get_posts','searchfilter');