Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action('pre_get_posts', 'realty_dosearch');
- /**
- *
- * Ejecuta la busqueda de propiedades
- */
- function realty_dosearch()
- {
- global $wp_query;
- // just search when is post type floor plan
- if ( $wp_query->query_vars['post_type'] != 'floor_plan' ) {
- return false;
- }
- // dont needed because you are sending the search to a custom post type page
- //$wp_query->query_vars['post_type'] = 'floor_plan';
- $bedrooms = get_query_var('bedrooms');
- if (!empty($area) && $area > 0) {
- $meta_query = array();
- $meta_query[] = array(
- 'key' => 'number_of_bedrooms',
- 'value' => $bedrooms,
- 'compare' => '=',
- 'type' => 'NUMERIC'
- );
- $wp_query->query_vars['meta_query'] = $meta_query;
- }
- }
- // }}}
- // {{{
- add_filter('query_vars', 'realty_query_vars');
- function realty_query_vars($query_vars)
- {
- $query_vars[] = 'bedrooms';
- return $query_vars;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement