title: How to filter a wordpress search by taxonomy terms?
body: <p>I have a custom post type named <em>projects</em> and a taxonomy named <em>type</em> and some terms of that taxonomy like <em>research</em>, <em>work</em>, <em>personal</em> in which a project can belong or not. I want to create a wordpress custom search for <em>projects</em> and a dropdown menu with all the terms of my taxonomy.</p>
  
  <p>In order to select only <em>projects</em> I was thinking to use something like this in my <em>function.php</em> file:</p>
  
  <pre><code>function SearchFilter($query) {
     if ($query-&gt;is_search) {
        $query-&gt;set('post_type', 'projects');
     }
     return $query;
  }
  add_filter('pre_get_posts','SearchFilter');
  </code></pre>
  
  <p>And to create a dropdown menu with <em>type</em> taxonomy terms I was thinking to use something like this in my <em>searchform.php</em> file:</p>
  
  <pre><code>&lt;label for="type"&gt;Type:&lt;/label&gt;
  &lt;select id="type" name="type"&gt;
     &lt;?php $project_types = get_categories('taxonomy=type'); ?&gt;
     &lt;option value=""&gt;All&lt;/option&gt;
     &lt;?php foreach ($project_types as $project_type) { ?&gt;
        &lt;option value="&lt;?php echo $project_type-&gt;term_id; ?&gt;"&gt;
           &lt;?php echo $project_type-&gt;name; ?&gt;
        &lt;/option&gt;
     &lt;?php } ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>They work individually but I don't know how to make them work together! I don't know how to handle the variable passed through the form into the function SearchFilter.</p>
  
  <p>Thank you in advance for help!</p>