WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I return all posts that match a specific taxonomy using <?php get_search_form(); ?>

For example: if a user enters a search query that matches the name of a tag or category, search.php will return all posts with a matching tag, or that fall into a matching category. I am working with a custom post type, and as of now, get_search_form(); seems to only return matches based on content and title alone. Please Help! Thanks.

share|improve this question
If somebody types in a tag or category, do you only want the posts with that tag/category, or do you want to include the regular search results in addition to the tag/category results? – Andy Adams Dec 20 '12 at 23:17
Have a look at the Relevanssi plugin – shea Dec 21 '12 at 1:54

use this function put in function.php file for cat=22 filter change your cat id for you mind

function my_search_form( $form ) { 

    $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
    <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    <input type="text" value="' . get_search_query() . '" name="s" id="s" />
   <input type="text" value="22" name="cat" id="scat" />
    <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />

    return $form;

add_filter( 'get_search_form', 'my_search_form' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.