Hi,
on a single page “Instrument” (custom post type), I’ve made a field type group called “Caractéristiques”, with 12 sub fields (Corps, Cordes, Vernis, etc…).
I’m trying to display a list of those sub fields (if not empty) with “Label” : “Value”.
Example:
Corps : Chêne
Cordes : Nylon
Vernis : Brillant
With this code, it was almost OK, but I have fields name instead of labels :
if( have_rows('acf-spec-instru') ):
while( have_rows('acf-spec-instru') ): the_row();
$subfields = get_field('acf-spec-instru');
if( $subfields ) { ?>
<ul>
<?php
foreach ($subfields as $spec => $value) {
if ( !empty($value) ) { ?>
<li><?php echo $spec; ?> : <?php echo $value; ?></li>
<?php }
} ?>
</ul>
<?php }
endwhile;
endif;
I know that I need to use get_sub_field_object() to get labels but I can’t figure it out how to use that function for all sub fields…
Any ideas ?
Thanks you.