Headless WordPress: ACF fields return empty once a post is created with WP-API
-
Setup:
- I have a Vue app that is using a separate WordPress install as a headless CMS.
- “ACF to REST API” plugin in installed.
- Custom Post-Type created with many ACF fields, some with default values.
Question:
Does anyone have a solution for when you create a post with the WP-API that has Advanced Custom Fields, and then having those custom fields returned in the response or when you run a GET request with the API?The fields do exist in the wp-admin once created with the API, but are not returned in the response. Unless you go into the admin area of WordPress and specifically click the “Update” button on that post. Only then do the ACF fields show up in the API response.
Essentially what is happening is the ACF fields are not wrting to the post_meta table in the database until the “Update” button is manually clicked. Is there a way publish a posts meta fields to the db externally?
Main Issue:
When using WordPress as a headless CMS, I can’t very well manually click that button in the admin area. There must be a way to create a post via the API and have all the ACF fields returned without having to explicitly save it in the WP admin area…right? Otherwise, what’s the point of using WordPress as a headless CMS if you can’t.
- The topic ‘Headless WordPress: ACF fields return empty once a post is created with WP-API’ is closed to new replies.