Home › Forums › Bug Reports › acf/save_post – wrong taxonomy field value › Reply To: acf/save_post – wrong taxonomy field value
Here is the code from the ACF Taxonomy field where the value is loaded. This function is called immediately after getting the value of the field when using get_field(). As you can see, if field[‘load_terms’] is true, the value is discarded and replaced with whatever is retrieved by wp_get_object_terms(). I have only included the important bits of this function and removed everything else.
function load_value( $value, $post_id, $field ) {
$value = acf_get_valid_terms($value, $field['taxonomy']);
// load_terms
if( $field['load_terms'] ) {
// get terms
$term_ids = wp_get_object_terms($post_id, $field['taxonomy'], array('fields' => 'ids', 'orderby' => 'none'));
$value = $term_ids;
}
return $value;
}
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!
Plugin boilerplates can do some of the heavy lifting during initial development. We look at four options to speed up your plugin creation. https://t.co/ZtMsdBxAHw
— Advanced Custom Fields (@wp_acf) June 5, 2023
© 2023 Advanced Custom Fields.
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.