I have a wysiwyg field in one of my flexible content blocks, and I call “wysiwyg” as a class for the block with the following code:
<?php
$content = get_sub_field('text');
$field = get_sub_field_object('text');
$fieldtype = $field['type']; ?>
<div class="<?php echo $fieldtype; ?>">
It works great, but I need to achieve the same thing with a wysiwyg field within an acf field group and I can’t get it to work the same way. This is what I have now:
<?php
$content = get_sub_field('twi_fields');
$text = $content['twi_text'];
$field = get_sub_field_object('$text');
$fieldtype = $field['type'];
?>
<div class="<?php echo $fieldtype; ?>">
To get the field object of a group field sub field you need to treat the group field as a repeater, not as an array.
while (have_rows('twi_fields')) {
// always happens once on a group field
the_row();
$text = get_sub_field('twi_text');
$field = get_sub_field_object('twi_text');
$fieldtype = $field['type'];
}