Open ciprianimike opened 6 years ago
I'm running into this as well, I've set up bidirectional relationships, and when one post type is updated, the other one's field value does get updated in WP, but not in rest APIs until the other post is re-published.
On a new post programmatically inserted, if i user update_field() the REST API won't show ACF fields, an "empty field": false is returned, i have to use update_post_meta, no matter if i publish the post and empty the post cache.
$post_id=wp_insert_post( $new_post );
// UPDATE CUSTOM FIELD //update_field( "weight", $weight, $post_id ); update_post_meta( $post_id, "weight", $weight );
//update_field( "birth_date", $birthday, $post_id ); update_post_meta( $post_id, "birth_date", $birthday );
//update_field( "chip", $chip, $post_id ); update_post_meta( $post_id, "chip", $chip );
$file = $_FILES['photo']; $attachment_id = media_handle_upload( 'photo', $post_id ); set_post_thumbnail( $post_id, $attachment_id );
wp_publish_post( $post_id ); clean_post_cache( $post_id );