Hi! 🙂
I have an archive page that shows certain posts and want to echo a list of selected ACF labels (not values) for each specific post.
I`ve got this in the loop:
<?php $field = get_field_object('custom_field_name'); if( $field['choices'] ): ?>
<ul>
<?php foreach( $field['choices'] as $value => $label ): ?>
<li><?php echo $label; ?></li>
<?php endforeach; ?>
</ul>
This however shows all the possible labels to select (not really the ones that are selected for the specific post).
<?php $field = get_field_object('custom_field_name');
$value = $field['value'];
if( $value ): ?>
<ul>
<?php foreach( $value as $label ): ?>
<li><?php echo $field['choices'][ $label ]; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>