This is pretty confusing… but it looks like “post object”, “post id” or “global $post” in the function’s description are expected to be an ACF Group Field ID, object, global… and NOT the post ID where the group is being used. So for example, not the home page ID.
“This function will take either a post object, post ID or even null (for global $post)”
And acf_get_field_groups() accepts an array of arguments, so passing $post_id/$post->ID won’t return anything. The default arguments indicate that’s also looking for all field_groups that have been published.
I can’t seem to find a function, that given a $post->ID will return all related field groups that are being used in that post.
My ultimate goal is to:
-> on page load, get’s id ($post->ID)
-> retrieve all field groups that have been used in this page
-> and then loop through each group, printing a different layout for each group.
I can do this easily right now using the “Flexible Content” field, because when I call get_fields, each layout has specific name, that I can check against.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.