times / acf-to-wp-api

Puts all ACF fields from posts, pages, custom post types, attachments and taxonomy terms, into the WP-API output under the 'acf' key
http://wordpress.org/plugins/acf-to-wp-api/
MIT License
203 stars 24 forks source link

ACF inserted with update_field not shown in REST API #58

Open ciprianimike opened 6 years ago

ciprianimike commented 6 years ago

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 );

geochanto commented 3 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.