Site logo

Archived topic

GeneratePress theme compatibility/handling of WooCommerce Product Search plugin

1 reply · Started by Peter on February 20, 2022

Viewing posts 1–2 of 2

Re: GeneratePress theme compatibility/handling of WooCommerce Product Search plugin
There's no official instructions specifically on how to set up WooCommerce Product Search plugin within Generate Press.
I'm not sure if WooCommerce Product Search plugin is compatible with Generate Press theme out of the box. Can you confirm?

I'm currently using this official GP snippet:

add_filter( 'generate_navigation_search_output', function() {
    printf(  
        '<form method="get" class="search-form navigation-search" action="%1$s">
            <input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
            <input type="hidden" name="post_type" value="product" />
        </form>', 
        esc_url( home_url( '/' ) ), 
        esc_attr( get_search_query() ),   
        esc_attr_x( 'Search', 'label', 'generatepress' ) 
    ); 
} );

And also, I'm using this GP snippet for the placeholder text:

add_filter( 'generate_navigation_search_output', function() {
    printf(
        '<form method="get" class="search-form navigation-search" action="%1$s">
            <input type="search" placeholder="Enter your search" class="search-field" value="%2$s" name="s" title="%3$s" />
        </form>',
        esc_url( home_url( '/' ) ),
        esc_attr( get_search_query() ),
        esc_attr_x( 'Search', 'label', 'generatepress' ) 
    ); 
} );

Is that correct?
Is it all that's needed?
Looking at my WooCommerce website (provided in the private notes), can you confirm if the WooCommerce Product Search plugin functionality is properly integrating with GP Theme?
Why are the search results so slow to come up?

Hi there,

the two Snippets you have aren't related to the Woocommerce Product Search plugin.
They are simply telling the GP Navigation Search to only search for the Product Post type.

To add Woocommerce Product Search you either need to add their widget or their shortcode.
If you want ti in the Navigation bar then you can:

1. Add a new Hook Element in Appearance > Elements.
https://docs.generatepress.com/article/hooks-element-overview/

2. Add to the hook content the woo shortcode: [woocommerce_product_search]
3. Set the Hook to generate_menu_bar_items
4. Check Execute Shortcodes
5. Set the Display Rules to Entire Site

Then disable the Navigation Search in the Customizer.

This archived topic is closed to new replies.