Archived topic
Search placeholder code overrides code restricting search to products
3 replies · Started by David Bennett on January 30, 2021
Viewing posts 1–4 of 4
I used the code from this documentation page to restrict search to products in WooCommerce.
generate_navigation_search_output.
Now I added the placeholder text code and while it shows the placeholder text OK, it overrides and stops the 'restrict search to products in WooCommerce' code from functioning.
Help.
Kind regards,
David
Hi there,
Try this code only:
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" />
<input type="hidden" name="post_type" value="product" />
</form>',
esc_url( home_url( '/' ) ),
esc_attr( get_search_query() ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
} );
That did it. Thanks. :-)
No problem :)
This archived topic is closed to new replies.