Restricting searches to categories in Woocommerce
-
Firts of all, thanks for the great plugin, but I have a small issue. I am using Woocommerce and I would like to search for products in different categories. I made this search form:
<form method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <div><label class="screen-reader-text" for="s">Search</label> <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" /> <?php wp_dropdown_categories(array( 'name' => 'product_cat', 'show_option_all' => 'Select a category', 'taxonomy' => 'product_cat')); ?> <input type="submit" id="searchsubmit" value="Search" /> <input type="hidden" name="post_type" value="product" /> </div> </form>
1. When there is no search word and no category assigned, all products are returned.
2. When I assign a category in the dropdown and no search word, 404 page is returned.
3. Search by keyword works fine, but no matter what category I assign.In Relevanssi I chose to index product and product_cat and Default operator for the search is AND. I am sure I am missing something I can’t figure what.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Restricting searches to categories in Woocommerce’ is closed to new replies.