Site logo

Archived topic

Navigation search to only search for woocommerce products

3 replies · Started by Gabriel on August 18, 2017

Viewing posts 1–4 of 4

Hello

I am trying to make my navigation search to search for only woocommerce products by using Snippets plugin and the following script but is not working:

add_filter( 'generate_navigation_search_output', 'tu_wc_navigation_search' );
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="%3$s" />
			<input type="hidden" name="post_type" value="products" />
		</form>',
		esc_url( home_url( '/' ) ),
		esc_attr( get_search_query() ),
		esc_attr_x( 'Search', 'label', 'generatepress' )
	);
}

The webpage is http://www.meicosolar.com

Thank you

Hi there,

Is the Code Snippet activated?

Change value="products" to value="product". It should be only "product" in querystring.

Nice catch! :)

This archived topic is closed to new replies.