Trying to manage and curate products that show up in search results queries. Is there a way to control this?
Thanks
This topic has 4 replies, 2 voices, and was last updated 1 month, 1 week ago ago by Jack Richardson
Trying to manage and curate products that show up in search results queries. Is there a way to control this?
Thanks
Hello @S,
Thank you for contacting us. You can configure only certain post types to be searchable (posts, products, product variations, and pages), layout of your search results and customize the Search results page. However, if you would like to apply additional customizations—such as excluding specific products from search results or excluding products from particular categories or tags—you may need to use an additional plugin, as this feature is not currently built into our theme.
You may explore available free plugins, but based on your request, a paid solution might be required. At this time, we are unable to recommend a specific plugin, but you may contact WooCommerce Support for further suggestions.
If you could kindly provide more details about your current setup or the specific results you wish to achieve, we would be happy to assist you further.
Best regards,
Jack Richardson
The 8Theme’s Team
I have products that are showing up, with similar names, categories, and tags. But some products I dont want showing but since they have a similar name or category, they show up. Id like to prevent some products from showing up. Thanks
Hello @S,
As you may know, according to the Envato Privacy Policy, we do not provide additional customization through our support service. However, as we always strive to assist our customers, you may try using the following snippet. You can add it either to your child theme’s functions.php file or by using a code snippets plugin such as Code Snippets (https://wordpress.org/plugins/code-snippets/):
add_filter('etheme_ajax_search_products_query', function($args) {
$products_exluded = array('717');
if ( array_key_exists('post__not_in', $args ) )
$args['post__not_in'] = array_merge($args['post__not_in'], $products_exluded);
else
$args['post__not_in'] = $products_exluded;
return $args;
});
function etheme_child_search_filter($query) {
if ($query->is_search() && !is_admin() && $query->is_main_query()) {
$post_not_in = $query->get( 'post__not_in');
if ( !is_array($post_not_in) )
$post_not_in = array();
$query->set( 'post__not_in', array_merge($post_not_in, array( '717' ) ) );
}
}
add_action( 'pre_get_posts', 'etheme_child_search_filter' );
Before:
Ajax search: https://gyazo.com/04a45e6c6784346457e3ef5b9f8257e9
Search results template: https://gyazo.com/2113b3d4306679a5286ef71e9e9b3e2e
After:
Ajax search: https://gyazo.com/8348a5bf4f709e476a7c7e636f9ac531
Search results template: https://gyazo.com/a2929c6cab47cf5f35ad2118b446159a
The value “717” represents the ID of the product you would like to exclude. You can find this ID in the product backend URL, as shown here: https://gyazo.com/42f76ef15d80ec1aa3905a77a0743184
You may also specify multiple IDs separated by commas.
Thanks for your understanding and respecting our support rules.
Best regards,
Jack Richardson
The 8Theme’s Team
You must be logged in to reply to this topic.Log in/Sign up