‘property-type’,
    ‘field’ => ‘slug’,
    ‘terms’ => $property_type
    );
    }
    }

    // if property-neighborhood is set add it to taxonomy query
    if(!empty($_GET[‘neighborhood’]) )
    {
    $property_neighborhood = $_GET[‘neighborhood’];
    if( $property_neighborhood != ‘any’ )
    {
    $tax_query[] = array(
    ‘taxonomy’ => ‘property-neighborhood’,
    ‘field’ => ‘slug’,
    ‘terms’ => $property_neighborhood
    );
    }
    }

    // if apartment-type is set add it to taxonomy query
    if(!empty($_GET[‘apartmenttype’]) )
    {
    $apartment_type = $_GET[‘apartmenttype’];
    if( $apartment_type_type != ‘any’ )
    {
    $tax_query[] = array(
    ‘taxonomy’ => ‘apartment-type’,
    ‘field’ => ‘slug’,
    ‘terms’ => $apartment_type
    );
    }
    }

    // if property-price is set add it to taxonomy query
    if(!empty($_GET[‘price’]) )
    {
    $property_price = $_GET[‘price’];
    if( $property_price != ‘any’ )
    {
    $tax_query[] = array(
    ‘taxonomy’ => ‘property-price’,
    ‘field’ => ‘slug’,
    ‘terms’ => $property_price
    );
    }
    }

    // if property-bedrooms is set add it to taxonomy query
    if(!empty($_GET[‘bedrooms’]) )
    {
    $property_bedrooms = $_GET[‘bedrooms’];
    if( $property_bedrooms != ‘any’ )
    {
    $tax_query[] = array(
    ‘taxonomy’ => ‘property-bedrooms’,
    ‘field’ => ‘slug’,
    ‘terms’ => $property_bedrooms
    );
    }
    }

    // if property-builder is set add it to taxonomy query
    if(!empty($_GET[‘builders’]) )
    {
    $property_builder = $_GET[‘builders’];
    if( $property_builder != ‘any’ )
    {
    $tax_query[] = array(
    ‘taxonomy’ => ‘property-builder’,
    ‘field’ => ‘slug’,
    ‘terms’ => $property_builder
    );
    }
    }

    // if two taxonomies exist then specify the relation
    $tax_count = count($tax_query);
    if($tax_count > 1)
    {
    $tax_query[‘relation’] = ‘AND’;
    }

    // if two meta query elements exist then specify the relation
    $meta_count = count($meta_query);
    if($meta_count > 1)
    {
    $meta_query[‘relation’] = ‘AND’;
    }

    // properties per page
    $properties_per_page = 1;

    // base query arguments for home page properties
    $search_args = array(
    ‘post_type’ => ‘property’,
    ‘posts_per_page’ => 1,
    ‘paged’ => get_query_var( ‘paged’ ),
    ‘orderby’ => ‘rand’,
    /*
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘news-cat’,
    ‘field’ => ‘slug’,
    ‘terms’ => ‘media’, // exclude media posts in the news-cat custom taxonomy
    ‘operator’ => ‘NOT IN’)
    ),
    */
    //’orderby’ => ‘taxonomy.taxonomy_cat meta_value’,
    //’ordertax’ => ‘ASC’,
    //’order’ => ‘DESC’
    //’orderby’ => ‘tax’
    //’tax_name’ => ‘taxonomy_name’
    );

    // if taxonomy query has some values then add it to base query
    if($tax_count > 0)
    {
    $search_args[‘tax_query’] = $tax_query;
    }

    // if meta query has some values then add it to base query
    if($meta_count > 0)
    {
    $search_args[‘meta_query’] = $meta_query;
    }

    // sorting meta data
    /*
    $search_args[‘orderby’] = ‘meta_value’;
    $search_args[‘meta_key’] = ‘propertyinfo_buildername’;
    if(!empty($_GET[‘orderby’]))
    {
    $search_args[‘meta_key’] = $_GET[‘orderby’];
    }
    */

    $search_args[‘order’] = ‘rand’;
    if (!empty($_GET[‘order’]))
    {
    $search_args[‘order’] = $_GET[‘order’];
    }

    // wp query
    $query = new WP_Query( $search_args );
    // print_r($query);

    $i = 0;
    if ( $query->have_posts() ) :
    while ( $query->have_posts() ) :
    $query->the_post();
    $i++;

    //display meta data
    $bg = get_post_meta($post->ID, ‘header_bg’, true);
    $buildername = get_post_meta($post->ID, ‘header_buildername’, true);
    $pricedetails = get_post_meta($post->ID, ‘propertyinfo_pricedetails’, true);

    ?>