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.
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.
Hi @bluecomet
Yes, hopefully soon I can add in a developer filter / action reference!
Cheers
E
Quick follow up question – how do I get a list of field group ID’s given a post ID?
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.
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);
You can achieve the same thing using get_field_objects($post->ID);