Home › Forums › Front-end Issues › Field Groups › Reply To: Field Groups
Hi @Stingo
Currently, there is no way to separate the fields into field groups with labels.
This will be possible in the soon to be released version5, but for now. You will need to hardcode the heading for each field group.
An easy way to do this is to create an array which contains all the field names for the field group, then loop through that and display the field like so:
<h2>Field Group Name</h2>
<?php
$fields = array(
'field_name_1',
'field_name_2',
'field_name_3'
);
?>
<?php if( $fields ): ?>
<ul>
<?php foreach( $fields as $field ):
$field = get_field_object( $field );
?>
<?php if( $field['value'] ): ?>
<li><?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Hope that helps
Thanks
E
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.