Add wp_terms_checklist() to a search form to search by taxonomy
-
Hi,
I have a jobs custom post type that is currently using the wp_dropdown_categories() function within a WP search form so people will be able to filter jobs by salary level and job type.
I would like to use input element checkboxes instead, so the user can select multiple taxonomy terms.
From what I gather this is best done with wp_terms_checklist(), however I cannot seem to get it work. The information in the developer docs seems sparse to say the least.
If I have a search form and wish to add two taxonomy terms lists for people to select items from how would I go about doing this?
Basically the form has a keyword search box then two taxonomy lists to choose from, where users either search by a combination of keywords and taxonomies or just keywords etc
Below is some pseudo code showing what I would like to achieve.
<form method="get" action="<?php echo esc_url(site_url('/')); ?>"> <label id="searchlabel" for="s">Search</label> <input id="s" name="s" type="search"> <input type="hidden" name="post_type" value="jobs" /> // add 1st instance of wp_terms_checklist() // job type taxonomy // add 2nd instance of wp_terms_checklist() // salary level taxonomy <input class="td search-jobs-button" type="submit" value="Search Jobs"> </form>
- The topic ‘Add wp_terms_checklist() to a search form to search by taxonomy’ is closed to new replies.