Support

Account

Home Forums ACF PRO Get all field groups related to post Reply To: Get all field groups related to post

  • 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.