For some reason, my twig templates are rendering empty <p>
tags and unwanted <br>
tags in my ACF Gutenberg blocks.
This is causing me to have to remove code indentation and formatting in order to remove these unwanted elements. For example, I have to change:
</div>
</div>
</div>
to:
</div></div></div>
in order to remove empty paragraphs.
Is there any way to retain code formatting while preventing these tags?
Seems to be an issue at this point. You can use the following workaround
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', function ($content) {
if (has_blocks()) {
return $content;
}
return wpautop($content);
});