Home Forums Backend Issues (wp-admin) Sorting the results of taxonomy field


Sorting the results of taxonomy field

  • We are trying to sort the results listed in a Taxonomy field of ACF. The words that we want to display as suggestions are added in a terms/taxonomy called Ingredients. Currently the terms are sorted alphabetically. However, we would like to implement a custom sorting rule where the results that start with the typed in part are listed on top of the list, followed by other suggestions. For example, if looking for we are searching for “sugar” the results would be something like:

    – sugar
    – sugar powder
    – brown sugar
    – palm sugar
    – …etc

    I know how to implement the sorting algorithm in PHP. However, the issue is where to place the code so that this change will be reflected in the WordPress admin panel when editing posts. I’ve added a picture to this post to visualize the part that we want to change.

    Any ideas? We’ve already tried Custom Taxonomy Order addon, but that one does not allow for custom sorting in code: and

    ACF taxonomy

  • bump, here is the image link that is not working in the original post:

  • The only way that you can alter the order of the terms in an ACF taxonomy field would be to use acf/fields/taxonomy/query and the sorting would need to be something you could apply to a term query using the order/orderby arguments.

  • I am having the same problem where I need to order the terms by php’s natural sort function.

    But through the acf/fields/taxonomy/query filter the only thing you can change is the orderby argument, but you can’t add a custom sort function or better yet sort the result before returning it.

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

You must be logged in to reply to this topic.