Support

Account

Home Forums Backend Issues (wp-admin) "Choices" automatically appear in alphabetical order in the post creation page

Solved

"Choices" automatically appear in alphabetical order in the post creation page

  • Hi,
    I have a field of type: “Radio Button” with many possible choices. I need the “Choices” automatically appear in alphabetical order in the post creation page. It’s possible? If possible, I will be very happy if you tell me how to do it.

    (I’m sorry my bad English)
    Thank you.

  • see https://www.advancedcustomfields.com/resources/acfload_field/

    
    add_filter('acf/load_field/name=field-name', 'short_choices');
    function sort_choices($field) {
      asort($field['choices']);
      return $field;
    }
    
  • Perfect! It was exactly what I needed. Thank you John Huebner!

    Only correcting for future users know when viewing this topic:
    A typo ‘short_choices’ should be ‘sort_choices’

    But the code worked perfect. Thank you again! Hugs.

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

The topic ‘"Choices" automatically appear in alphabetical order in the post creation page’ is closed to new replies.