Archived topic
Generatepress + GP premium and search result in woocomerce
7 replies · Started by Artur on May 20, 2021
Don't see add to basket button and price.
Hi there,
are you using the Navigation Search ?
If so the snippet here will change its behaviour to display product search results:
https://docs.generatepress.com/article/generate_navigation_search_output/#woocommerce-products
yes I use navigation search how to fix it
In this link:
https://docs.generatepress.com/article/generate_navigation_search_output/#woocommerce-products
Under Woocommerce Products - add that PHP Snippet to your site.
This doc explains how to add PHP:
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')
);
});
but not working https://meblowykramik.pl
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