Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- THE RESULTS -->
- <div id="Container">
- <!-- WARNING IF NO RESULTS -->
- <div class="alert alert-danger alert-dismissible fail-message" role=alert>
- <button type=button class=close data-dismiss=alert aria-label=Close><span aria-hidden=true>×</span></button>
- No items were found matching the current filters.
- </div>
- <?php
- // todo - sanitise and validate
- $property_location = $_GET['property-location'] != '' ? $_GET['property-location'] : '';
- $bedrooms = $_GET['bedrooms'] != '' ? $_GET['bedrooms'] : '';
- $bathrooms = $_GET['bathrooms'] != '' ? $_GET['bathrooms'] : '';
- $tax_query = array();
- if( !empty($property_location) ) {
- $tax_query[] = array(
- 'taxonomy' => 'property-location',
- 'field' => 'slug' ,
- 'terms' => $property_location
- );
- }
- $meta_query = array();
- if( !empty($bedrooms) ) {
- $meta_query[] = array(
- 'key' => 'bedrooms',
- 'value' => $bedrooms ,
- 'compare' => '>='
- );
- }
- if( !empty($bathrooms) ) {
- $meta_query[] = array(
- 'key' => 'baths',
- 'value' => $bathrooms ,
- 'compare' => '>='
- );
- }
- $args = array(
- 'post_type' => 'listing',
- 'posts_per_page' => -1,
- 'tax_query' => $tax_query,
- 'meta_query' => $meta_query,
- 'fields' => 'ids'
- );
- $listingSearch = new WP_Query( $args );
- if ( $listingSearch->have_posts() ) {
- while ( $listingSearch->have_posts() ) {
- $listingSearch->the_post();
- get_template_part( 'loop', 'grid' );
- } // end while
- } // endif
- else {
- // else there are no posts/error
- // this is handled by the javascript
- }
- // END OF LOOP
- ?>
- </div><!-- #Container -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement