Order of custom field items in seclect filter

WordPress Business Themes Forums Responsive Themes Directory Theme Order of custom field items in seclect filter

Order of custom field items in seclect filter

August 10, 2017
 Alex

  • 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.
    August 10, 2017 at 4:16 pm
  • Josh
    Josh
    Super Guru 13,887 points

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

    August 10, 2017 at 4:40 pm

  • Alex
    Newbie 4 points

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

    August 10, 2017 at 4:44 pm
  • Josh
    Josh
    Super Guru 13,887 points

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

    August 10, 2017 at 5:05 pm

  • Alex
    Newbie 4 points

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

    August 10, 2017 at 5:24 pm
  • Josh
    Josh
    Super Guru 13,887 points

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

    August 11, 2017 at 3:22 pm

  • 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!

    August 13, 2017 at 4:58 pm
  • Josh
    Josh
    Super Guru 13,887 points

    Thanks for sharing Alex :)

    August 14, 2017 at 12:28 pm
Viewing 8 posts - 1 through 8 (of 8 total)

Didn't find what you were after?

Chat with us now

or contact our support team