Support

Account

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