If you’re using an Advanced Custom Fields WYSIWYG and displaying it using a GenerateBlocks Headline block, you might have noticed that it strips your text of any paragraphs.
I don’t fully understand why, but I know it has something to do with WPAutoP, and Tom from GenerateBlocks has shared some code with me to fix this issue.
You can copy the PHP below and paste it either into a Code Snippet or inside of the Functions.php file in your child theme (read more on adding PHP).
add_filter( 'generateblocks_dynamic_content_output', function( $output, $attributes ) {
if ( isset( $attributes['dynamicContentType'] ) && 'post-meta' === $attributes['dynamicContentType'] ) {
$id = isset( $attributes['postId'] ) ? $attributes['postId'] : get_the_ID();
$custom_field = get_field_object( $attributes['metaFieldName'], $id );
if ( isset( $custom_field['type'] ) && 'wysiwyg' === $custom_field['type'] ) {
$output = wpautop( $output );
}
}
return $output;
}, 10, 2 );
Once this code is on your website, the WYSIWYG content should display in paragraphs correctly.