• hello, I have built my store on top of your theme and so far I have been using woocommerce blocks quite well but one of the long lasting issues I have had is the default search that comes with the theme.

    I am wondering if it be possible to change this so it just searches woocommerce products currently if the search is used this is how its displaying:

    I am keen to make this better but I’m not sure where to begin

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @arandomscott,

    Thanks for reaching out!

    Unfortunately, it isn’t possible to change the search post type out-of-the-box, and all posts of any post type that contain the keywork will show up in the search results.

    However, if the following code were to be added to the functions.php file of a child theme or using a plugin like WP Code to add a PHP snippet, the default search functionality should be altered to only display posts of the ‘product’ post type:

    add_filter( 'pre_get_posts', 'search_products_only' );
    function search_products_only( $query ) {
            if ( $query->is_search ) {
                $query->set( 'post_type', array( 'product')  );      
    }
     return $query;
    }

    Note that this isn’t an official code fix, it’s just something that worked on my test site for this specific case. We can’t provide support for or troubleshoot this code if it doesn’t work on your configuration.

    Let me know if this helped!

    I’m brand new to WordPress and I’m helping my brother build a website for his business.

    I looked at the design of your site navigation bar and really will be needing to do something similar with the company logo centered above the page names for his new site,where and how do I do this. I’m using the Go Theme with Coblocks.

    I’m very sorry if this is a basic question, I’m having real trouble finding any good tutorials that actually use the Go Theme, any help and advice for a true beginner would be greatly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Default Search’ is closed to new replies.