Support

Account

Home Forums Add-ons Repeater Field category taxonomy in repeater not saving

Solved

category taxonomy in repeater not saving

  • Not sure what I’m doing wrong. Have a taxonomy select in a repeater, where I’m trying to allow the user to select their category for a list. But it always resets back to the first available category after saving.

    Have Load and Save Terms and using Term Object for the return. Everything loads in the front end, but it simply won’t save any selections.

  • Load/Save terms will not work correctly with a taxonomy field in a repeater. The reason is that each works independently of the others. Each time the terms are saved to the post the previous terms are removed. Save and load terms cannot be used for repeater sub fields.

    See https://developer.wordpress.org/reference/functions/wp_set_post_terms/, when ACF sets the post terms the $append argument is set to false.

    In order to do this in a repeater you have to build your own save terms function using an acf/save_post action. In the action you need to loop over repeater and build an array of terms to add and then set the post terms yourself.

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.