Category Filter in Reverse Alphabetical & Custom Filter Ordering Question

New home Forums Gold Add-on Troubleshooting Category Filter in Reverse Alphabetical & Custom Filter Ordering Question

This topic contains 4 replies, has 2 voices, and was last updated by  dll416 1 week, 4 days ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #51233

    dll416
    Member

    My category filter dropdown is ordering in reverse alphabetical and I can’t get it to show in alphabetical order. I feel like I am missing some simple setting. Can you please help?

    Also I have a custom filter that has 5 Minutes or Less, 6 – 10 Minutes, and 11 – 15 minutes and it is treating the numbers as strings and putting the 11 before the 5, how can I get the custom filter dropdown to order in proper numerical order?

    #51244

    Hi there,

    Thanks for getting in touch with us.

    Could I kindly ask if you could please send me a link to your website so that I can take a closer look at this for you to assist you further with a solution to get this resolved as soon as possible?

    Thanks for your time and I look forward to hearing back from you.

    Best regards,
    Dylan

    #51977

    dll416
    Member
    This reply has been marked as private.
    #51990

    Hi there,

    Thanks for the response and information.

    To sort the left list alphabetically in ascending order and to assign the right dropdown numerically, please can you add the following JavaScript code to Maps > Settings > Advanced Settings > Custom JS:

    jQuery(document).ready(function(){
    $ = jQuery;
    var custom_field_filter = $("[data-field-id='1']");
    var select = $('#wpgmza_filter_select');
    if (select.length > 0) {
        select.html(select.find('option').sort(function(x, y) {
        	return $(x).text() > $(y).text() ? 1 : -1;
        }));
        select.val(0);
    }
    
    if (custom_field_filter.length > 0) {
        custom_field_filter.html($("[data-field-id='1'] option").val(function(){
        	return this.text.match(/\d+/);
        }).sort(function (a, b) {
        	var a = parseInt(a.value,10), b = parseInt(b.value,10);
        	return a < b ? -1 : 1;
        })).val('');
    }
    });

    After saving the code, could I kindly ask you to test it again and please let me know if it works as expected?

    Thank you.

    Best regards,
    Dylan

    #52017

    dll416
    Member

    Works perfectly! Thanks!

    #52030

    Hi there,

    Thank you for letting me know and I am really glad to hear that helped.

    Please do let me know if there is anything else I can assist you with.

    Best regards,
    Dylan

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.