title: Custom Wordpress Database Query
body: <p>I am trying to create a custom filter which would query the database in three parameters - post content, meta value and taxonomy term. </p>
  
  <p>Here is the form code </p>
  
  <pre><code> &lt;form role="search" method="get" class="search-form" action="&lt;?php echo home_url( '/' ); ?&gt;/search-results"&gt;
  
   &lt;div class="search_jobs"&gt;
   &lt;?php do_action( 'job_manager_job_filters_search_jobs_start', $atts ); ?&gt;
  
   &lt;div class="item"&gt;
   &lt;input type="text" name="keyword" placeholder="Keyword" /&gt;
   &lt;/div&gt;
  
   &lt;div class="item"&gt;
  
   &lt;input type="text" name="location"  placeholder="All Locations" /&gt;
   &lt;/div&gt;
  
  &lt;div class="item"&gt;
  &lt;label for="search_categories"&gt;&lt;?php _e( 'Category', 'wp-job-manager' ); ?&gt;&lt;/label&gt;
  &lt;?php wp_dropdown_categories( array( 'taxonomy' =&gt; 'job_listing_category', 'hierarchical' =&gt; 1, 'show_option_all' =&gt; __( 'All Job Categories', 'wp-job-manager' ), 'name' =&gt; 'search_categories', 'orderby' =&gt; 'name' ) ); ?&gt;
  &lt;/div&gt;
  
  &lt;div class="search-s"&gt;
  &lt;input type="submit" class="search-submit" value="Search" /&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>This is the query I have so far</p>
  
  <pre><code>&lt;?php
  $s_key = $_GET['keyword'];
  $s_loc = $_GET['location'];
  $s_cat = $_GET['search_categories'];
  
  global $wpdb;
  
  $searchquery = $wpdb-&gt;get_results( 
  "
  SELECT * FROM wp_posts WHERE 1
  
  AND post_status = 'publish' AND post_type = 'job_listing'
  
  AND post_content LIKE '%$s_key%' AND meta_value LIKE '%$s_loc%' 
  "
  );
  ?&gt;
  </code></pre>
  
  <p>The important part is that keyword is just a plain text input field and it searches for keywords in the post content. It works fine this way.
  Location is meta value and key is named _job_location.
  Search categories is a dropdown of taxonomy terms. Taxonomy is called job_listing_category.
  I need to have this query searching for all the parameters or for example just one if user decides to use just one field. After the query I have loop which works fine so I didn't paste it. </p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Thanks.</p>