Advertisement
Guest User

Untitled

a guest
Oct 17th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.88 KB | None | 0 0
  1. <?php // WP_Query arguments
  2.                         $price_min = $_GET['price-min'];
  3.                         $price_max = $_GET['price-max'];
  4.                         $waterfront = (isset($_GET['waterfront']) ? 'waterfront' : false);
  5.                         $large_groups = (isset($_GET['large-groups']) ? 'large-groups' : false);
  6.                         $near_city = (isset($_GET['near-city']) ? 'near-city' : false);
  7.                         $args3 = array(
  8.                             'post_type' => array('villa'),
  9.                             'posts_per_page' => 4,
  10.                             'meta_query' => array(
  11.                                 'relation' => 'AND',
  12.                                 array(
  13.                                     'key' => 'destination',
  14.                                     'value' => $place_id,
  15.                     'compare' => '='
  16.                                 ),
  17.                             )
  18.                         );
  19.  
  20.                         if ($waterfront !== false || $near_city !== false || $large_groups !== false) {
  21.                             $args3['meta_query'][] = array(
  22.                                 'relation' => 'OR',
  23.                                 array(
  24.                                     'key' => 'villa_type',
  25.                                     'value' => '"waterfront"',
  26.                                     'compare' => 'LIKE',
  27.                                 ),
  28.                                 array(
  29.                                     'key' => 'villa_type',
  30.                                     'value' => '"large-groups"',
  31.                                     'compare' => 'LIKE',
  32.                                 ),
  33.                                 array(
  34.                                     'key' => 'villa_type',
  35.                                     'value' => '"near-city"',
  36.                                     'compare' => 'LIKE',
  37.                                 ),
  38.                             );
  39.                         }
  40.  
  41.                        
  42.  
  43.                         if ($price_min !== false || $price_max !== false) {
  44.                             $args3['meta_query'][] = array(
  45.                                 'relation' => 'AND',
  46.                                 array(
  47.                                     'key' => 'single_villa_prices_%_price',
  48.                                     'value' => '"'.$price_min.'"',
  49.                                     'compare' => '>=',
  50.                                 ),
  51.                                 array(
  52.                                     'key' => 'single_villa_prices_%_price',
  53.                                     'value' => '"'.$price_max.'"',
  54.                                     'compare' => '<=',
  55.                                 )
  56.                             );
  57.                         }
  58.  
  59.  
  60.                         // The Query
  61.                         $results = new WP_Query($args3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement