Home Forums ACF PRO Sorting Selected Relationship Values in Admin


Sorting Selected Relationship Values in Admin

  • Sorting the relationship query in the admin with a filter is fairly trivial (e.g., but is there an equivalent for the values chosen? For example, I want the _selected_ items to remain alphabetical and not based on the clicked order. Is this possible? Maybe with the javascript API?

  • Sadly not possible from ACF itself.
    But with some creative jQuery it is certainly possible;

    $('.acf-relationship .selection .values ul.acf-bl.list.values-list').each(function () {
        var mylist = $(this);
        var listitems = mylist.children('li').get();
        listitems.sort(function (a, b) {
            return $(a).text().toUpperCase().localeCompare($(b).text().toUpperCase());
        $.each(listitems, function (idx, itm) {
            var txt = $(this).text();


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

The topic ‘Sorting Selected Relationship Values in Admin’ is closed to new replies.