WP Residence Help WP Residence Help

  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required / Technical how to: How i can add new fields / new sorting order for the properties list.

Technical how to: How i can add new fields / new sorting order for the properties list.

5381 views 1

This document works for standard property list and  for property category pages (if you chose standard display).

The property list page (property_list.php) and the property category pages (taxonomy.php) are displaying the lists using a template file called normal_map_core.php

In this file, we load another template file that contains the HTML code for the filters

get_template_part('templates/property_list_filters');

in the  property_list_filters.php  you would find the HTML code for the city, category, order etc dropdowns.  Also in this file, you would find the buttons that change the list format (from grid to list or vice versa). If you want to change or add new filters this is the place where you put the HTML code.

The “listing filtering action” –  is made via ajax. That means you would get new results without loading the page but if you leave this page the filter selection will be reset.

The filters action start when you make a selection on one of the dropdowns. At that time we call a JavaScript function called start_filtering. For ex in ajaxcalls.js at line 1525

   $('.listing_filters_head li').on('click', function (event) {

        var pick, value, parent;
        pick = $(this).text();
        value = $(this).attr('data-value');
        parent = $(this).parent().parent();
        parent.find('.filter_menu_trigger').text(pick).append('').attr('data-value', value);
        parent.find('input:hidden').val(value);

        wpestate_start_filtering(1);


    });

 

The wpestate_start_filtering()  function is defined in ajaxcalls.js around line 870. In this function, we read the value of the filters and we send those to a PHP function called ajax_filter_listings.  If you add new filters or option for filters you need to make sure you read those new values in this function and that you pass them correctly to the PHP function.

The PHP function wpestate_ajax_filter_listings() is located in ajax_functions.php around line 4000. In there we read the variables sent via ajax call  (the $_POST variables)  and compose the arguments array that will be used in a wp_query instruction.

If you add  new filters or parameters you must add those to the $arg array

For ex – in case you add a new “order by ” you need to put a new case situation in the switch block at line 4098. Any new taxonomy arguments needs to be added in the tax_query

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

After the wp_query is done the property list is returned to the JavaScript function in a form of html code and this function will “append it” to the current page.

success: function (data) {
jQuery('#listing_loader').hide();
jQuery('#listing_ajax_container').empty().append(data);
jQuery('.pagination_nojax').hide();
restart_js_after_ajax();

 

How to hide a value from the dropdowns with CSS (from theme options)

You can hide a specific value from the dropdown categories with css

For exemple to hide “rentals” in a drowpdown, you can use this css code:

ul[aria-labelledby="a_filter_action"] > li[data-value="rentals"] {
display:none;
}

Technical how to | Custom Code Required

Related Articles

  • Technical: Change the Schedule Tour Email Text and the Form Default Message
  • Property list filter customization
  • Technical – How to Change the Minimum Image Dimensions for Property Uploads in WPResidence
  • Introduction to WPResidence Header Customization

Help Categories

  • 18Agent, Agency & Developers
  • 5Blog Posts & Blog Lists
  • 38Elementor Shortcodes Built-In
  • 45FAQ
  • 15Footer
  • 5Getting Started
  • 37Header
  • 2IDX & MLSImport
  • 6Installation & Setup
  • 23Installation FAQ
  • 23Maps & Location Settings
  • 21Multi-Language - Third Party Plugins
  • 6Other Third party Plugins
  • 20Pages
  • 4Payments & Monetization
  • 20Property Lists, Categories & Archive
  • 37Property Pages & Layouts
  • 31Search & Filtering
  • 162Technical how to | Custom Code Required
  • 8Technical: Actions and filters
  • 6Technical: Child Theme
  • 86Theme Options & Global Settings
  • 7Translations & Languages
  • 16WPBakery Shortcodes
  • 50WPEstate / WPResidence Translate Plugin
  • 51WPResidence / WPEstate CRM
  • 50WPResidence 5.0 Documentation
  • 8WPResidence Elementor Studio

Join Us On

Powered by WP Estate - All Rights Reserved
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API