Support

Account

Home Forums ACF PRO Map/post ACF field to meta_key value where meta_key field has multiple values Reply To: Map/post ACF field to meta_key value where meta_key field has multiple values

  • Using a select that allows multiple values is a good choice it holds arrays in the database and it’s probably the easiest field to deal with. ACF stores these fields as serialized array.

    You already have the values populated into the acf field by your comment, so putting them back into the other fields you would do something like this.

    
    add_action('acf/save_post' 'update_cptonomies_field_name');
    function update_cptonomies_field_name($post_id) {
      $values = get_field('acf_field_name', $post_id);
      delete_post_meta($post_id, 'cptonomies_field_name');
      if ($values) {
        foreach ($values as $value) {
          add_post_meta($post_id, 'cptonomies_field_name', $value, false);
        }
      }
    }