UPDATE:
It seems the issue is that this doesn’t work if I set the flag in the field group to use the image as the featured image. I can’t therefore quite achieve what I need which is:-
1. If no image has been added to the custom post then populate the ACF Field and the featured image with the default image.
2. If an image is uploaded to the custom post then populate the ACF field and the featured image with the uploaded image.
The second part works by just configuring the image field to use the uploaded image as the featured image but then requirement 1 doesn’t work.
Any pointers would be great.
Thanks
I have now slightly amended the code to :-
$default_image = update_field('_thumbnail_id_pyjamas', 400);
//$values = get_fields( $post_id );
// var_dump($default_image);
//die('VALUES');
$data = array(
'ID' => $post_id,
'post_title' => $title,
'post_name' => sanitize_title( $title ),
'_thumbnail_id_pyjamas'=> $default_image
);
Still no joy.
Can anyone see what I am doing wrong?
Thanks