Site logo

Archived topic

Woocommerce search and product tags

3 replies · Started by Bob on March 9, 2018

Viewing posts 1–4 of 4

Hello,

I found the answer to the first part of my question in the link below, which was how do I change the search function to respond like the Woocommerce product search. https://generatepress.com/forums/topic/change-search-parameters-in-navigation-menu/

But I'd also like to have the search produce results for Woocommerce product tags. Currently when I search for a tag, there are no results.

So specifically, the question is whether the search results can produce both what it's doing now (I used the code from GitHub in the code snippets plugin) plus tags results?

Thank you.

This code is actually preferred:

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

As for searching taxonomies, it might be worth checking out a plugin like this: https://wordpress.org/plugins/relevanssi/

Thanks Tom, I'll also check out the link.

No problem! :)

This archived topic is closed to new replies.