Your address will show here +12 34 56 78

Home Forums WP RESIDENCE – Real Estate WordPress Theme FORUM Add sort by Title in WP RESIDENCE Properties List sort options

This topic contains 0 replies, has 1 voice, and was last updated by  Anna 2 years ago.

  • Author
    Posts
  • #123181

    Anna
    Keymaster

    If you don’t know php it will be quite difficult to do this.

    You have this code in libs/ajax_functions.php

    
    switch ($order){
    case 0:
    $meta_order='prop_featured';
    $meta_directions='DESC';
    $order_by = 'meta_value_num';
    break;
    
    case 1:
    $meta_order='property_price';
    $meta_directions='DESC';
    $order_by='meta_value_num';
    break;
    case 2:
    $meta_order='property_price';
    $meta_directions='ASC';
    $order_by='meta_value_num';
    break;
    case 3:
    $meta_order='';
    $meta_directions='DESC';
    $order_by='ID';
    break;
    case 4:
    $meta_order='';
    $meta_directions='ASC';
    $order_by='ID';
    break;
    case 5:
    $meta_order='property_bedrooms';
    $meta_directions='DESC';
    $order_by='meta_value_num';
    break;
    case 6:
    $meta_order='property_bedrooms';
    $meta_directions='ASC';
    $order_by='meta_value_num';
    break;
    case 7:
    $meta_order='property_bathrooms';
    $meta_directions='DESC';
    $order_by='meta_value_num';
    break;
    case 8:
    $meta_order='property_bathrooms';
    $meta_directions='ASC';
    $order_by='meta_value_num';
    break;
    }
    

    Same steps as for the code above, first you need to add the option “by title” in the select dropdown

    After that you need to make sure the option value is correctly selected in javascript (this is made in ajax so js is part of the process)

    Then add in the code above the new options like this

    case x:
    $meta_order='';
    $meta_directions='DESC';
    $order_by='title';
    break;

    see this link also
    https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    —–

    Add sort by property lot size

    In property_list_filters.php around line 93 there is an array with the dropdown options – listing_filter_array (the on from above) . Put there your options and make sure they are visible on front end

    When you select the an option a function is triggered in js . Is called start_filtering() and is in ajax_calls.js You could do a console.log(order) to make sure the value for the options is correctly read.

    The selection is sent to function ajax_filter_listings() in ajax_functions.php

    At line 1657 you have the switch function and you can insert there your new options code

    *this is how we would post 11 and 12 for the new size options

    case 9:
    $meta_order=’property_size’;
    $meta_directions=’DESC’;
    $order_by=’meta_value_num’;
    break;
    case 10:
    $meta_order=’property_size’;
    $meta_directions=’ASC’;
    $order_by=’meta_value_num’;
    break;

    And to make your new filter option as default sort order

    In property_list.php you have the original switch code (line 149) – add there the new size options

    After that, just before the switch you have

    $order=get_post_meta($post->ID, 'listing_filter',true );

    Just set $order to 9 or 10

    NOTE: these instructions for property size are for theme version Wp Residence V 1.11.4

You must be logged in to reply to this topic.