Home Forums ACF PRO Relationship – Add selected to the top


Relationship – Add selected to the top

  • Okay bit of a strange one but I have someone asking whether it would be possible to reverse the order when adding relationship items in admin.

    Currently by default when you add a new item in the relationship field it adds it to the bottom, below all the other selected items in the field.

    What I would like to do is have new items added to the top.

    Here is a quick screenshot to try and explain what i’m trying to do

    Would really appreciate it if someone could help me out with this 🙂

  • There’s really no simple way of doing this. In the ACF core javascript, the new element is appended to the list, and I don’t really see a way of hooking into that easily. If this is a client’s request, the short answer is no. The long answer is yes, but it’ll cost them some $$$.

    Basically you’d need to hijack what is natively done and things can get sticky from there. Or…. you can jump into the ACF core javascript files and change this: this.$list('values').append( html ) to this.$list('values').prepend( html ). But of course, that’ll only last until they update ACF, which is horrible idea.

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

The topic ‘Relationship – Add selected to the top’ is closed to new replies.