I am trying to programatically create posts of a certain custom-post-type. Within the custom post type i've enabled 'show in rest api' and set a slug.
Within ACF i've setup a group that contains custom fields, and 'show this field if' is set to the custom post type. The fields show up on the created posts but they remain empty.
From my code:
$response = $client->request('POST', 'mycustomposttype', [
'json' => [
'title' => $title,
'status' => 'publish',
'fields' =>
[
'post_title' => $title,
'post_content' => '',
'post_excerpt' => 'Weer een leuke',
'post_status' => 'publish',
'post_type' => 'mycustomposttype',
'post_date'=> $datepublished
]
'meta' => /*my acf*/
[
'titel' => $title,
'externalurl' => $link,
'externalimageurl' => $image,
'categorie' => $category,
'country' => $country,
'datetimepublished' => $datepublished
]
]
]);
I thought i was wrong in naming the custom field type and have tried to name that array differently: meta_input, acf but the fields wont populate, maybe i'm searching wrong but i also can't find how it should be named ( still thinking this is whats going wrong).
It has to be something simple but i can't figure it out. Or can they only be populated when the post is already created?