Answer the question
In order to leave comments, you need to log in
How to search by category or taxonomy in Wordpress?
The essence of the problem.
There is a taxonomy "category_media" (from the WP Media Category Management plugin)
There are a couple of categories (categories) that I would like to search. Let their IDs be - 3, 5.
I want to display a search form:
- input where we fill in the text
- input[type=radio] - category 3 - input[type=radio] - category
5
- input[type=radio] - category_media taxonomy
- input submit
It's also interesting how to make your own output template for each heading when searching.
Thank you!
Answer the question
In order to leave comments, you need to log in
WP has a search bar template that you can override by putting a searchform.php file in your theme and putting your desired template in it. For example like this:
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div>
<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" />
<input type="radio" name="cat" value="21">
<input type="radio" name="cat" value="22">
<input type="radio" name="cat" value="23">
<input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />
</div>
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question