Home › Forums › General Issues › Sort ASC a select field in backend › Reply To: Sort ASC a select field in backend
You can use either an acf/load_field or an acf/prepare_field filter. Using the former will cause a permanent change to the field when/if you edit it. Using the latter will only alter the order when an editor is using the field.
The values of a select field are located in $field['choices']
and is an array of field value => label pairs as shown in this guide https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/
You can use this function to short the values of the choices array https://www.php.net/manual/en/function.asort.php
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.