WP Residence Help WP Residence Help

  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required / Technical how to: Advanced Search explained – advanced search results page

Technical how to: Advanced Search explained – advanced search results page

3156 views 0

The advanced search results page is made by publishing a page with the the template “Advanced Search Results” template. The file for this template is advanced_search_results.php

*** IMPORTANT: we only use WordPress wp_query ( and an array of arguments that is usually named $args) when doing the actual search.  Wordpress has an extended article about wp_query here : https://codex.wordpress.org/Class_Reference/WP_Query .If you plan do changes on search script read their documentation first.

The search algorithm is different for advanced search type 2 compared with advanced search type 1 and also if you are using custom fields instead of default fields.

at line 51 we check if the search type is different than type 2

if( !isset($_GET['is2']) ){

after that we check if is custom advanced search

if( $custom_advanced_search==='yes' ){

If we use custom fields we are asking for the search arguments using function  wpestate_search_results_custom () . If you have default fields then the search arguments array will be returned by the function wpestate_search_results_default()

When you have the default fields and advanced search type 1 or 3

The wpestate_search_results_default is located in libs/searchfunctions.php at like 335

Categories parameters like city ,category or area are set by buulding the 4 arrays ($categ_array, $action_array, $city_array and $area_array) that are inside the ‘tax_query’

'tax_query' => array(
'relation' => 'AND',
$categ_array,
$action_array,
$city_array,
$area_array,

Price, bathrooms or bathrooms are search using  ‘meta_query’ parameter .

 

 

 

When you have custom fields and advanced search type 1 or 3

The wp_query arguments  array is created via function wpestate_search_results_custom located in searchfunctions.php at line 3

Here we get the custom fields info using
$adv_search_what = get_option('wp_estate_adv_search_what','');
$adv_search_how = get_option('wp_estate_adv_search_how','');
$adv_search_label = get_option('wp_estate_adv_search_label','');
$adv_search_type = get_option('wp_estate_adv_search_type','');

and then we loop trough the custom fields and build the arguments array,

Same as in the case of default fields we use

Categories parameters like city ,category or area are set by buulding the 4 arrays ($categ_array, $action_array, $city_array , $area_array, $countystate_array) that are inside the ‘tax_query’

'tax_query' => array(
'relation' => 'AND',
$categ_array,
$action_array,
$city_array,
$area_array,

$countystate_array

Price, bathrooms or bathrooms are search using  ‘meta_query’ parameter .

Please note that there are also 2 filters  in advanced_search_results.php

add_filter( 'posts_orderby', 'wpestate_my_order' ); // at line 96 - is ordering the listing by the featured property and the id parameter - The featured listings will appear first (set in $arg array) and they will be orderd by id (set by filter)

add_filter( 'posts_where', 'wpestate_title_filter', 10, 2 ); // used when you have keyword search

 

When you have advanced search type 2 (custom fields are not applicable for type 2) 

In this case the arguments array is build using wpestated_advanced_search_tip2()  located in searchfunctions.php at line 678.

Categories parameters like city ,category or area are set by buulding the 4 arrays ($categ_array, $action_array and $location_array) that are inside the ‘tax_query’
'tax_query' => array(
'relation' => 'AND',
$categ_array,
$action_array,
$location_array

 

 

After the arument array is built  (the $args variable)  we check to see if theadvacend search results page is a classic one or a half map one

if ( $property_list_type_status == 2 ){
get_template_part('templates/half_map_core');
$half_map_results=1;

}else{
get_template_part('templates/normal_map_core');
}

The actual wp_query is made in the file above using the $args you set here. The display of the results is also made in those files.

 

See also Technical how to: Advanced Search explained – advanced search forms

Technical how to | Custom Code Required

Related Articles

  • Introduction to WPResidence Header Customization
  • Understanding WPResidence Header Types: An Overview
  • Customizing the WPResidence Logo Display
  • Configuring the Primary Navigation Menu in WPResidence

WP Residence Documentation

  • 1. General
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 2. Installation
  • 3. Installation FAQ
  • 4. Advanced Search
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 5. Agent, Agency & Developers
  • 6. Property Page
  • 7. Properties List
  • 8. Property Taxonomies
  • 9. Property Custom Template
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • Theme Options
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • Translation
  • FAQ
  • Pages
  • Header
  • Footer
  • Google or Open Street Maps
  • Payment Options
  • Plugins
    • Included Plugins
    • Third Party Plugins – IDX Compatibility
    • Third Party Plugins – Multi Languages
    • Third party Plugins – Other
  • Technical
    • Technical how to | Custom Code Required
    • Technical: Child Theme
  • Theme Updates

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API