Support

Account

Home Forums General Issues Assign a taxonomy term to items in Post Object Reply To: Assign a taxonomy term to items in Post Object

  • You need to create an acf/save_post action. You need to set the priority of your action < 10 so that it runs before ACF saves the value.

    You can get the new value of the field from $_POST['acf']['field_XXXXXXX'] where field_XXXXXXX is the field key of your relationship field.

    You can get the old value from the database at this point using get_field('relationship_field_name', $post_id, false), the 3rd argument in the call tells acf not to format the value

    In both cases the value will be an array of post IDs. You then need to compare the two arrays and add or remove terms from each post based on that comparison using wp_add_object_terms().