Archived topic
Search Bar
5 replies · Started by Leandro on August 8, 2018
Hello there. im using the Widget Search bar and need to only search Woocommerce products instead of post, etc. I found this code on forum buy only works with the other search bar.
function tu_wc_navigation_search() {
printf(
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" class="search-field" value="%2$s" name="s" title="%2$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' )
);
May u help with this?
Sory for my poor english,
Regards
Hi there,
You would need to use a child theme: https://docs.generatepress.com/article/using-child-theme/
Then copy searchform.php from the parent theme, and add it to your child theme: https://github.com/tomusborne/generatepress/blob/2.1.3/searchform.php
Then you'll need to edit the file in your child theme. After line 15 (https://github.com/tomusborne/generatepress/blob/2.1.3/searchform.php#L15), add this:
<input type="hidden" name="post_type" value="product">
Let me know if this helps or not :)
Hei Tom, works perfect! ty so much.
Now im trying to add the Shipping cart aling with the logo, instead of been on Primary Menu. How can i add it?
Regards,
Hi there,
Any examples of the look you're going for?
Hei Tom, sure. Screenshot
https://imageshack.com/a/img923/706/WAybDV.jpg
Move the Cart and price to that section, aling whith logo and search bar!
Regards
Ah, you would likely need a custom solution, or you'd need to find a widget which displays the cart like that.
The GP cart menu item is only built to work within a menu currently.