I am trying to update the value of an acf taxonomy field by using update_field()
if I use wp_set_object_terms() the data appears in the backend form fields but is not saved to the post until I manually save the post.
I can’t get update_field() working with any value… Should I be passing the term object or the ID?
//works but does not save data to the field
wp_set_object_terms( $route_id, intval( $grade_object->term_id), ‘grade’ );
//I believe this is what I need to do but I cannot get it to work
update_field(‘field_52e7f08dec08a’, intval( $grade_object->term_id) , $route_id);
I have the same problem. Posted an entry here yesterday:
I have found a solution!
It’s all about the output function rather than the save function.
get_field('field_name') wasn’t outputting a value
I needed to use
get_field(field_id) (it will look something like this –
I generally do use field ID’s as they’re supposed to be more reliable, for some reason I used the field name here and that was causing the problem.
Hope that helps someone
Im using the field_id but i think something crazy is wrong, because it get the default “welcome to wordpress” blog post, yet i have set up the field so filter by my custom post type that i created, which it populates correcly when im updating the post and the relation field.
And when running a get_field(field id….) i get the correctly value + default wp blog post + the title of the entry repeated 21 times. No logic there.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future.— Advanced Custom Fields (@wp_acf) January 6, 2023
© 2023 Advanced Custom Fields.