Based on a number of github threads like this one, I’m not the only one experiencing this issue: WordPress is adding <p> tags willy-nilly throughout code that shouldn’t have it.
What’s happening is this: the wpautop filter is firing double, essentially, if you ever use any of the following when rendering an ACF block for Gutenberg. That means it’s wrapping every line with <p> tags in every block on the page, if any of the blocks use any of the following to render:
- Core WordPress function the_content()
- Core WordPress function the_excerpt()
- Core WordPress filter ‘the_content’
- ACF core function the_field()
To make things worse, even if you’re getting around all of these, but there are any shortcodes inside your ACF content area (for example, outputting which do use any of the above, then the whole page will still break.
Here’s what you can do to put a bandaid on this:
I think it’s possible there’s a better solution out there, something along the lines of Elliot Conden’s example here, but I don’t want to add complexity to troubleshooting this later on the assumption that Gutenberg will eventually fix this.
There’s been a Trac ticket awaiting review on this topic for the last 8 weeks, so hopefully they get to that soon.
Leave a Reply