I am having trouble accessing Fields in a Field Group using ACF Pro.
I have one Field Group set up named “Menu Template”. Menu Template contains a Flexible Content Field with various layouts. I then have three posts (Menu A, Menu B, and Menu C) in a custom post type called “Menus”. Each post has access to the Field Group Menu Template.
In each of these three Menus, the user enters different information into a field “Days Available”, for example,
– Menu A is available Mon-Tue;
– Menu B is available Thu-Sat;
– Menu C is available Sun
I want to be able to access all three of these “Days Available” values outside of their respective posts, for example, if I were in page-random.php I could loop through an array and have access to the Days Available value from each of Menu A, Menu B, Menu C.
What I have tried –
The only option I have that works is using get_field_object() and specifying an ID for each post (seems a bit messy).
Using get_posts() and specifying the post_type gives back all the posts but I don’t have access to the ACF Fields (not that I can see anyway).
Last option (which I haven’t tried) might be to query the database directly using wpdb. This looks to be the solution to an earlier post somewhat similar (https://support.advancedcustomfields.com/forums/topic/get-a-field-object-outside-of-the-post-context/).
Any thoughts / help / advice greatly appreciated.