Site logo

Archived topic

Generatepress + GP premium and search result in woocomerce

7 replies · Started by Artur on May 20, 2021

Viewing posts 1–8 of 8

Don't see add to basket button and price.

yes I use navigation search how to fix it

I use this

add_filter ('generation_navigation_search_output', function () {
printf (
'<form method = "get" class = "search-form navigation-search" action = "% 1 $ s">
<input type = "search" class = "szukaj -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', 'generatedpress')
);
});

David have some problem with that

https://docs.generatepress.com/article/generate_navigation_search_output/#woocommerce-products

1. Place holder

When I add that code need 2 click to enter text. Without that 1 click.

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' )
);
} );

Hi there,

Have you added multiple snippets of the same generate_navigation_search_output filter?

Last time I checked I saw your site is rendering multiple search forms.

Do you want the search function to search WooCommerce product AND have the search bar get a placeholder text?

If so, we can rewrite the code coming from that documentation into a single filter.

Example:

add_filter( 'generate_navigation_search_output', function() {
    return sprintf(
        '<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" />
            <input type="hidden" name="post_type" value="product" />
        </form>',
        esc_url( home_url( '/' ) ),
        esc_attr( get_search_query() ),
        esc_attr_x( 'Search', 'label', 'generatepress' ) 
    ); 
} );

This is how it will behave - https://share.getcloudapp.com/WnuYL8K7

This archived topic is closed to new replies.