I have a custom rest api endpoint that utilized get_fields() function. From what I can tell, this is our point of failure for some of our custom post types. We have multiple custom post types.
Here is our story in bullet point form.
1. Register custom post type, add acf fields to custom post type.
2. Created a custom importing script that takes a web service in json format and imports the data into the custom post type using wp_insert_post.
4. It is hard to tell where things actually go wrong. We often times pull the database from our live site and then import it into our local websites. I believe this is where something breaks. But, i have not been able to confirm this bit yet.
5. We used the ACF to REST API plugin and that added the acf: object to what is returned from our custom endpoint. In our custom endpoint where we use get_fields() – that value is returning an empty array and thus shows acf: false.
6. Today, I went into the ACF field group settings and enabled the Show in REST API option.
7. I checked the rest api endpoint for custom post type, the one that is built into wordpress and I see the values in the acf object of all of my custom fields.
How does ACF add those values to the rest api endpoint?
Is there a fix for get_fields() function for this scenario?
UPDATE: This thread might be related and I will in the next importer I make, i will save the data using the field keys. I am going to try using get_field_object to get the key using the name of the fields.