Home Forums Feature Requests Get Fields in a Group or Tab for Output


Get Fields in a Group or Tab for Output

  • Is there a function to obtain a list of fields in a field group or layout?

    I basically want to mirror the field groups / tabs to the output, and the get_fields() function only shows all the fields as one list. I need to break it up, either according to the tabs or field groups or flexible content layout rows in the back end.

    • Elliot

    • July 26, 2013 at 3:36 pm

    Hi @bluecomet

    You can load the fields from a field group like so:

    $fields = apply_filters('acf/field_group/get_fields', array(), $field_group_id);
  • Hello, elliot!
    Thanks for the great plugin.
    Why don’t you create separate function for this with description in documentation? This way is not very clearly without digging in support forum.
    I think it would be very useful to get fields by group ID, not all fields by post ID.

    • Elliot

    • August 20, 2013 at 2:25 pm

    Hi @bluecomet

    Yes, hopefully soon I can add in a developer filter / action reference!


  • Quick follow up question – how do I get a list of field group ID’s given a post ID?

    • Elliot

    • September 3, 2013 at 2:39 pm

    Hi @bluecomet

    You can see examples of this in core/controllers/input.php on line 137:

    // get field groups
    $filter = array( 
    	'post_id' => $post_id, 
    $metabox_ids = array();
    $metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
  • Sorry to revive an old thread but has this changed in V5? I simply would like to get all custom fields name/values for a post grouped by group ID.

    • Daniel

    • July 14, 2015 at 4:44 am

    I am also having the same issue. Looks like this filter no longer works in V5

    $fields = apply_filters(‘acf/field_group/get_fields’, array(), $field_group_id);

    • Daniel

    • July 14, 2015 at 4:47 am

    You can achieve the same thing using get_field_objects($post->ID);

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Get Fields in a Group or Tab for Output’ is closed to new replies.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.