Reputation: 9
I need to create a search for (wordpress site)form having 2 input fields. 1. A dropdown field, consisting all categories. and 2. a basic text input which would search the whole site.
I was using a plugin (advance-wp-query-search-filter.1.0.10) but it is not working. When i select a category, the meta title and the meta description is getting generated but no posts is getting displayed.
I was trying to get all the categories and combine with the single input text search button. code for getting all the categories into a dropdown menu:
<li id="categories">
<h2><?php _e('Categories:'); ?></h2>
<form action="<?php bloginfo('url'); ?>" method="get">
<div>
<?php wp_dropdown_categories('show_count=1&hierarchical=1&taxonomy=coupon_category'); ?>
<input type="submit" name="s" value="view" />
</div>
</form>
</li>
what i want is, there should be 2 inputs (dropdown & text input) and a common search button which would submit both or any one input which is provided by the user.
My single input text search button is working fine. How can i combine multiple input fields ?
EDITED CODE -
<form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>">
<div>
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" />
<?php wp_dropdown_categories('show_count=1&hierarchical=1&taxonomy=coupon_category'); ?>
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>
The above code, displays a search box with 2 inputs, which are dependent on each other. I want it to work independently having a common submit button. if i input a category and search, the search results should be according to the category, and if i search only a normal text input, the result should be according to the input text. and if i input both the fields, i want the search result to get populated with respect to the input text box.
Upvotes: 0
Views: 1387
Reputation: 51
You can try just filtering the search from whole website with a cat== inside the displaying loop of your search page.
Upvotes: 0