title: WP_Query custom post type by multiple custom fields
body: <p>Alright guys, I'm in way over my head.</p>
  
  <p>I'm trying to build a filter for a custom post type, 'Villas'. These villas have multiple custom fields, these custom fields exist in a group named 'features'.</p>
  
  <p>I've build a search / filter form that POST's the data, which I'm then able to capture using a $_GET request.</p>
  
  <p>The data I'm sending includes: <br>
  - <strong>Region, type, style</strong> select fields; <br>
  - <strong>Sea view, Sea access, Swimming pool, Reform project</strong> checkboxes; <br>
  - <strong>Price</strong> input field</p>
  
  <p>What I'm trying to accomplish is get a query going that filters all 'Villas' using the form values. After extensive googling I found it is possible to loop through custom post_type's with custom fields by using meta_key's. Basicly what I'm trying to do is:</p>
  
  <pre><code>    $propertyPrice      = $_GET['price'];
      $propertyRegion     = $_GET['region'];
      $propertyType       = $_GET['type'];
      $propertyStyle      = $_GET['style'];
      $hasSeaview         = $_GET['seaview'];
      $hasSeaAccess       = $_GET['sea-access'];
      $hasSwimmingPool    = $_GET['swimming-pool'];
      $hasReformProject   = $_GET['reform-project'];
  
      if( isset($propertyPrice) || isset($propertyRegion || isset($propertyType)) || isset($propertyStyle) || isset($hasSeaview) || isset($hasSeaAccess) || isset($hasSwimmingPool) || isset($hasReformProject)) {
          $args = array(
              'meta_query' =&gt; array(
                  'relation' =&gt; 'OR'
                  array(
                      'key'   =&gt; 'property-price', 
                      'value' =&gt; $propertyPrice,
                  ),
                  array(
                      'key'   =&gt; 'property-region', 
                      'value' =&gt; $propertyRegion,
                  ),
                  array(
                      'key'   =&gt; 'property-type', 
                      'value' =&gt; $propertyType,
                  ),
                  etc......
              )
          );
      }
  </code></pre>
  
  <p>However, I cannot for the life of me figure out how to filter through the posts with variable meta values, send from the form.</p>
  
  <p>If anyone could point me in the right direction, it would be extremely appreciated.</p>
  
  <hr>
  
  <p>To give you an idea, this is what the filter looks like:</p>
  
  <p><a href="http://i.stack.imgur.com/zg9Ew.png" rel="nofollow">Custom post type filter</a></p>
  
  <hr>
  
  <p><strong>EDIT</strong> <br>
  After xphan's suggestion I edited my code like so, however the var_dump returns nothing even though the _GET's are filled correctly.</p>
  
  <pre><code>&lt;?php
      $propertyPrice      = $_GET['price'];   
      $propertyRegion     = $_GET['region'];
      if($propertyRegion === 'all') { $propertyRegion = array('ibiza-city', 'southwest', 'north', 'east', 'center'); }
      $propertyType       = $_GET['type'];
      if($propertyType === 'all') { $propertyType = array('villa', 'apartment', 'plot'); }
      $propertyStyle      = $_GET['style'];
      if($propertyStyle === 'all') { $propertyStyle = array('rustic', 'modern'); }
      $hasSeaview         = $_GET['seaview'];
      if( isset($hasSeaview) ) { $hasSeaview = 1; }
      $hasSeaAccess       = $_GET['sea-access'];
      if( isset($hasSeaAccess) ) { $hasSeaAccess = 1; }
      $hasSwimmingPool    = $_GET['swimming-pool'];
      if( isset($hasSwimmingPool) ) { $hasSwimmingPool = 1; }
      $hasReformProject   = $_GET['reform-project'];
      if( isset($hasReformProject) ) { $hasReformProject = 1; }
  ?&gt;
  
  &lt;?php
  
  echo $propertyRegion .'&lt;br&gt;';
  echo $propertyType .'&lt;br&gt;';
  echo $propertyStyle .'&lt;br&gt;';
  echo $propertyPrice .'&lt;br&gt;';
  ?&gt;
  &lt;?php  if( isset($propertyPrice) || isset($propertyRegion) || isset($propertyType) || isset($propertyStyle) || isset($hasSeaview) || isset($hasSeaAccess) || isset($hasSwimmingPool) || isset($hasReformProject)) { 
      $args = array(
          'post_type' =&gt; 'villas',
          'meta_query' =&gt; array(
              array(
                  'key'   =&gt; 'property-price', 
                  'value' =&gt; $propertyPrice
              ),
              array(
                  'key'   =&gt; 'property-region', 
                  'value' =&gt; $propertyRegion,
                  'compare' =&gt; 'IN'
              ),
              array(
                  'key'   =&gt; 'property-type', 
                  'value' =&gt; $propertyType,
                  'compare' =&gt; 'IN'
              ),
              array(
                  'key'   =&gt; 'property-style', 
                  'value' =&gt; $propertyStyle,
                  'compare' =&gt; 'IN'
              ),
              array(
                  'key'   =&gt; 'sea-view', 
                  'value' =&gt; $hasSeaview
              )
          ) 
      ); 
  
      $the_query = new WP_Query( $args );
  
      if ( $the_query-&gt;have_posts() ) {
          while ( $the_query-&gt;have_posts() ) {
              $the_query-&gt;the_post(); ?&gt;
  
              &lt;?php var_dump($the_query-&gt;the_post()); ?&gt;
  
  &lt;?php
          }
      } else {
          // no posts found
      }
      /* Restore original Post Data */
      wp_reset_postdata();
  
  }
  </code></pre>