Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACF inserted with update_field not shown in REST API #58

Open
ciprianimike opened this issue Dec 4, 2017 · 1 comment
Open

ACF inserted with update_field not shown in REST API #58

ciprianimike opened this issue Dec 4, 2017 · 1 comment

Comments

@ciprianimike
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants