I’m trying to insert a value into a group of fields in an acf array from another post entry.
$post_field = get_fields($id);
$result = wp_insert_post(array(
'post_type' => 'institution',
'post_title' => get_post($id)->post_title,
'post_status' => 'publish',
'meta_input' => array(
'author' => $post_field['author'],
'primary_info' => $post_field['primary_info']
),
));
Here $post_field['primary_info']
is an array:
$post_field['primary_info'] = ["full_name" => "name",
"short_name" => "short_name"]
And in the post type "institutes" – a group of nested fields.
A new post entry is created in the institutes, but only the "author" field is filled in, and the "primary information" field group remains empty.
'meta_input' => array(
'author' => $post_field['author'],
'primary_info_full_name' => 'name'
),
This solved the problem, however I have a lot of fields in the group, so it is inconvenient
You need to sign in to view this answers