Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // WP_Query arguments
- $price_min = $_GET['price-min'];
- $price_max = $_GET['price-max'];
- $waterfront = (isset($_GET['waterfront']) ? 'waterfront' : false);
- $large_groups = (isset($_GET['large-groups']) ? 'large-groups' : false);
- $near_city = (isset($_GET['near-city']) ? 'near-city' : false);
- $args3 = array(
- 'post_type' => array('villa'),
- 'posts_per_page' => 4,
- 'meta_query' => array(
- 'relation' => 'AND',
- array(
- 'key' => 'destination',
- 'value' => $place_id,
- 'compare' => '='
- ),
- )
- );
- if ($waterfront !== false || $near_city !== false || $large_groups !== false) {
- $args3['meta_query'][] = array(
- 'relation' => 'OR',
- array(
- 'key' => 'villa_type',
- 'value' => '"waterfront"',
- 'compare' => 'LIKE',
- ),
- array(
- 'key' => 'villa_type',
- 'value' => '"large-groups"',
- 'compare' => 'LIKE',
- ),
- array(
- 'key' => 'villa_type',
- 'value' => '"near-city"',
- 'compare' => 'LIKE',
- ),
- );
- }
- if ($price_min !== false || $price_max !== false) {
- $args3['meta_query'][] = array(
- 'relation' => 'AND',
- array(
- 'key' => 'single_villa_prices_%_price',
- 'value' => '"'.$price_min.'"',
- 'compare' => '>=',
- ),
- array(
- 'key' => 'single_villa_prices_%_price',
- 'value' => '"'.$price_max.'"',
- 'compare' => '<=',
- )
- );
- }
- // The Query
- $results = new WP_Query($args3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement