Hello! Got some more fun questions for you folks! So I’ve got a page that has a loop that iterates over a set of custom post types and then will display things from those custom post types. In this instance, I need to pull data I have in Advanced Custom Fields, just a few text fields. I’ve pulled the object and when I print out the props for it, it looks like this:
As you can see, this doesn’t look like a regular post type object that gets pulled from ACF.
Anyone have any ideas on how I can get this object to show the ACF fields within it?
Do I need to re-fetch using the slug of the object?
Hello How are you creating the Custom Post Types? First of all, you have to make sure that the Custom Post Types are shown in the REST API. If you are using a plugin you’ll have an option to set Show in REST API to true. If you are creating them coding you’ll need to set show_in_rest (documentation) to true in your code.
From there, I think the best approach could be to fetch the endpoint of all your Custom Post Types, which should have the same format as common posts, and each one will have the ACF field in the response. This way, with just one fetch, you could have all the clients from post_type=client with the ACF info of each one.
For example in our test, you can go to movies Post Type (we just have one movie), and there you could get its ACF.
Not sure if this is what you need, let us know if you have more questions