Search bar

Good afternoon!

I currently have a search bar and it is working just fine. However, I have an Ecwid account connected to WordPress with all my products. When I use the search bar to search for any of the products it says that nothing matches the search. That’s very unfortunate because I want the visitors to be able to find the products they are looking for. I’m assuming the search bar is not connected to the store plugin? Is there any way I could connect those?

Thank you,
Yana

Hi Yana,

Please add this code to the functions.php file of the child theme:


add_action( 'pre_get_posts', 'search_result_post_types' );

function search_result_post_types( $query ) {
	
    if ( $query->is_search ) {
	$query->set( 'post_type', array( 'post', 'page', 'products' ) );
    }
    
    return $query;
    
}

Hope this helps.

Hello!
Thank you so much for your reply.

I am not sure of the process. Do I add this to the functions.php and then reinstall the child theme? Or do I just add it on the computer and that’s it?

Thank you,
Yana

I have inserted the code just into the file without re-uploading the child theme or anything like that and nothing happened btw.
Thank you

Hey Yana,

The above code won’t work in your case, As their site says:

Ecwid stores the product data in a secure cloud storage. The product pages are displayed on the fly when a customer browses your store. Basically, the products are not stored on the website, that’s why the website search can not find product pages while searching through the site pages and blog posts.

So you need to enable the local storage mode for products, to do this go to WordPress Dashboard > Ecwid Store > Advanced and check the corresponding option.

For further assistance please see https://support.ecwid.com/hc/en-us/articles/360000633445-FAQ-about-Ecwid-stores-on-Wordpress#sitesearch or you can check this thread as well https://www.ecwid.com/forums/showthread.php?t=16449

Please note that we cannot provide support for third party plugins or scripts as our support policy states due to the fact that there is simply no way to account for all of the potential variables at play when using another developer’s plugin or script. Because of this, any questions you have regarding setup, integration, or troubleshooting any piece of functionality that is not native to X will need to be directed to the original developer.

Thank you for your understanding.

Thank you so much! This fixed the issue! I didn’t realize it was this simple. I really appreciate your help

You’re welcome!
We’re glad we were able to help you out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.