Created
June 15, 2016 10:20
-
-
Save Balamir/2b968112b5bd0d9a26743ceb76fdcaef to your computer and use it in GitHub Desktop.
Wordpress - Search Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $paged = (get_query_var('paged')) ? get_query_var('paged') : ((get_query_var('page')) ? get_query_var('page') : 1); | |
| $search = array( | |
| 'post_type' => 'properties', | |
| 'post_status' => 'publish', | |
| 'orderby' => $date_order, | |
| 'order' => $order, | |
| 'pagination' => true, | |
| 'posts_per_page' => 10, | |
| 'paged' => $paged, | |
| 'meta_query' => array( | |
| 'relation' => 'AND', | |
| array( | |
| array( | |
| 'key' => $sale_rent, | |
| 'meta_value' => array($min_price, $max_price), | |
| 'compare' => 'BETWEEN', | |
| ), | |
| ), | |
| array( | |
| array( | |
| 'key' => 'square_footage', | |
| 'meta_value' => $min_sqft, | |
| 'compare' => '>=', | |
| ), | |
| array( | |
| 'key' => 'square_footage', | |
| 'meta_value' => $max_sqft, | |
| 'compare' => '<=', | |
| ), | |
| ), | |
| ), | |
| 'tax_query' => array( | |
| 'relation' => 'AND', | |
| array( | |
| 'taxonomy' => 'prop-type', | |
| 'field' => 'slug', | |
| 'terms' => $property_type, | |
| ), | |
| array( | |
| 'taxonomy' => 'prop-neighborhoods', | |
| 'field' => 'slug', | |
| 'terms' => $neighborhood, | |
| ) | |
| ), | |
| ); | |
| $properties = new WP_Query($search); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment