Hi! How can I echo the field name to use it as class?
Gonna need more information here I think.
But it looks like it’s a repeater field (or a flex field/ group field) they are all repeaters and you already have the field name
if (get_sub_field('col_left')) {
?><div class="col_left"><?php the_sub_field('col_left'); ?></div><?php
}
Yes. In my example it is a flexible content field .
Thanks for your answer. I’m searching for something like this:
$fieldname = field name of the marked the_sub_field('col_left');
<div class="<?php echo $fieldname; ?>">Blablabla</div>
Try this:
$fieldname = get_sub_field_object('col_left');
$value = $fieldname['_name']; ?>
<div class="<?php echo $value; ?>">Blablabla</div>
This should give you
<div class="col_left">Blablabla</div>