I have setup a wp multisite where you have the option to transfer a post from one site to another. All taxonomies and fields should be transferred too. Now I'm stuck on the part where I have to link the Author field (which is a custom post_type) that is a Relationship.
register_extended_field_group([
'title' => __('News', 'janes-admin'),
'key' => 'group_scope_news',
'location' => [
Location::where('post_type', 'post')
],
'fields' => [
Relationship::make(__('Authors', 'janes-admin'), 'authors')
->postTypes(['employee']),
],
'style' => 'box',
]);
I can retrieve the $fields and then loop over them and insert them with the update_field() function
if (!empty($fields)) {
foreach ($fields as $field => $value) {
update_field($field, $value, $new_translation_id);
}
}
This works for all the basic fields but it won't add the Authors. I'm guessing I should insert these authors seperately but not sure about that.