Home › Forums › Feature Requests › 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.
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.
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);
The topic ‘Get Fields in a Group or Tab for Output’ is closed to new replies.
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.