title: How make AND and OR wordpress query
body: <p>I made a (taxonomy) query with relation OR and that works. </p>
  
  <p>But I have a couple of filters that I woud combine. </p>
  
  <p>Then I should use AND (relation) but when the visitor not set an filter (in dropdown see filter) than query shows nothing. </p>
  
  <p>How to make a query with AND and OR function?</p>
  
  <pre><code>$taxonomy1 = $_GET['soort'];
  $taxonomy2 = $_GET['merk'];
  $taxonomy3 = $_GET['hefcapaciteit'];
  $taxonomy4 = $_GET['brandstof'];
  
  $the_query = new WP_Query(array(
      'posts_per_page' =&gt; 10,
      'tax_query' =&gt; array(
          'relation' =&gt; 'OR',
          array(
             'taxonomy' =&gt; 'soort',
             'field' =&gt; 'term_taxonomy_id',
             'terms' =&gt; $taxonomy1,
  
          ),
          array(
             'taxonomy' =&gt; 'merk',
             'field' =&gt; 'term_taxonomy_id',
             'terms' =&gt; $taxonomy2,
  
          ),
          array(
             'taxonomy' =&gt; 'hefcapaciteit',
             'field' =&gt; 'term_taxonomy_id',
             'terms' =&gt; $taxonomy3,
  
          ),
          array(
             'taxonomy' =&gt; 'brandstof',
             'field' =&gt; 'term_taxonomy_id',
             'terms' =&gt; $taxonomy4,
  
          ),
      ),  
  ));
  
  ?&gt;
  
  &lt;?php while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post();  ?&gt;  
  </code></pre>
  
  <p>Below the filter:</p>
  
  <pre><code>&lt;form action="&lt;?php bloginfo('url'); ?&gt;/zoek" method="get"&gt;
     &lt;div class="large-12 medium-12 columns select"&gt;
        &lt;?php wp_dropdown_categories('taxonomy=soort&amp;order=ASC&amp;show_option_none=Soort&amp;name=soort'); ?&gt;
        &lt;?php wp_dropdown_categories('taxonomy=merk&amp;order=ASC&amp;show_option_none=Merk&amp;name=merk'); ?&gt;
        &lt;?php wp_dropdown_categories('taxonomy=hefcapaciteit&amp;order=ASC&amp;show_option_none=Hefcapaciteit&amp;name=hefcapaciteit'); ?&gt;
        &lt;?php wp_dropdown_categories('taxonomy=brandstof&amp;order=ASC&amp;show_option_none=Brandstof&amp;name=brandstof'); ?&gt;
        &lt;a href="/occasions" class="button blauw"&gt;reset&lt;/a&gt;  
        &lt;input type="submit" class="button" value="zoek"&gt;  
     &lt;/div&gt;
  &lt;/form&gt; 
  </code></pre>