Custom WooCommerce PHP Search with Dropdown

I added the following code to a php widget on my site in order to search the site by product category via a drop down box.

<form role="search" method="get" id="searchform" action="<?phpbloginfo('siteurl'); ?>"<div>
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" />
<?php wp_dropdown_categories ($args = array(
'taxonomy' => 'product_cat',)); ?>
<input type="submit" id="searchsubmit" value="Search" /></div></form>

I can’t figure out why any the search isn’t returning any hits. When I look at the search results something seems off. I see only the search term and the category number (example=”?s=flour&cat=17″) Any guidance on where to start reading is most appreciated.

Related posts

2 comments

  1. By default WordPress doesn’t search custom post types when a search query is performed, to solve the issue you are facing, add the following hidden field to your widgets form definition

    <input type="hidden" value="product" name="post_type">

Comments are closed.