Order of custom field items in seclect filter


  • Alex
    Newbie
     
    4 points

    I am having a problem with order of items in the filter for a select custom field.
    I created and a select type custom fields and pasted select options in a specific order. But when I see them displayed by the filter in search widget – they have a completely different order. Please see the image attached for better understanding.
    Thanks!

    Attachments:
    You must be logged in to view attached files.

    Josh
    Josh
    Super Guru
     
    13,599 points

    Hello Alex,
    The search dropdown will display items in an ascending order



    Alex
    Newbie
     
    4 points

    Can I override this? I need them to be in specific order


    Josh
    Josh
    Super Guru
     
    13,599 points

    Unfortunately you will need to edit theme core files to change this.



    Alex
    Newbie
     
    4 points

    I don’t mind editing. I just need to know which file to look into. Thanks!


    Josh
    Josh
    Super Guru
     
    13,599 points

    Hello Alex,
    Check theme core files DT >framework >class



    Alex
    Newbie
     
    4 points

    Found it.
    File called class_core.php

    around line 2249 there’s a line:
    // NOW RE-ORDER AND DISPLAY
    asort($statesArray);
    replace ‘asort’ with any of the php sorting functions
    check this URL for references
    http://php.net/manual/en/array.sorting.php
    I changed mine to ‘rsort’ and it did the trick.

    Thanks!


    Josh
    Josh
    Super Guru
     
    13,599 points

    Thanks for sharing Alex :)


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

You must be logged in to reply to this topic.