Support

Account

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;
    }