Support

Account

Home Forums Backend Issues (wp-admin) Weird Behavior with Taxonomy field Reply To: Weird Behavior with Taxonomy field

  • The behavior you’re seeing is what will happen. Taxonomy fields with save/load terms cannot really be used as sub fields of a repeater.

    For save terms, as each row is updates wp_set_post_terms() is called. This has the effect of deleting any current terms and setting the new ones.

    For load terms it will only load the terms set in the last field update.

    This can be an issue and it is not covered in the documentation. Because of the way ACF works the taxonomy field cannot know what happened the last time the value was saved. This same behavior can be seen if you create 2 top level taxonomy fields that pull terms from the same taxonomy. Basically what this means is that any post can only have a single occurrence of a taxonomy field for any taxonomy if you want to use save/load terms.

    If you want to have save/load terms in a repeater (or flex field) you need turn these settings off. You must build an acf/save_post action. In this action you need to loop over the repeater, get all of the terms from all rows and then call wp_set_post_terms() yourself including the entire list of terms to be set.