I’m using ACF in wordpress.
I created a field group named my_group
that contains a WYSIWYG field called my_content
. Then I created another field that clones my_group
.
Inside a flexible content field, one of the layouts is a clone of my_group
. When I output the WYSIWYG field (my_content
) from the clone, the <p>
tags are missing.
Actual:
This is some text
Another line of text
Expected:
<p>This is some text</p>
<p>Another line of text</p>
I can work around this by adding the the_content filter:
echo apply_filters('the_content', $my_content);
I understand that get_field()
normally formats wysiwyg content, but here I’m pulling the field data from a flexible content field array:
$flexible_content = get_field('flexible_content');
foreach ($flexible_content as $row) {
switch ($row['acf_fc_layout']) {
case 'my_group':
$my_group = $row['my_group'];
$my_content = $row['my_content'];
echo apply_filters('the_content', $my_content);
// echo $my_content;
break;
}
}
Sometimes I do not see this behavior and it works fine when I use this method, but other times I get this unexpected behavior.
Why does the wysiwyg field inside a cloned group sometimes output without <p>
tags? Is there a better way to handle it than using the_content
filter?