I don’t know when this started happening, but I just noticed that my ACF Pro 5.2.9 WYSIWYG field is wrapping my opening shortcodes and their corresponding closing shortcodes in separate paragraph tags, resulting in empty paragraphs being rendered on the page. Experimentation with putting all my content on one line, deleting the paragraph tags and using hard returns, manually deleting the wrapping tags, and other variations all gave me similar results. Sometimes my first paragraph of content wouldn’t be rendered inside paragraph tags at all. I didn’t find anything about this in the forums, so I’m submitting this bug report.
Correct. The standard WYSIWYG doesn’t appear to have this problem. Here’s an example with the standard WYSIWYG on top and the ACF editor in the History tab below.
It sure does look like ACF wysiwyg is handling things differently.
I’m fairly sure the wysiwyg field is not created using wp_editor() (not 100% sure why but it’s possible wp_editor was introduced after the wysiwyg field).
Just to make sure, do you have the latest version of ACF and WordPress? Do you run any filters or hooks on the ACF fields which could interfere?
There’s a lot of posts recently about the behaviour of the wysiwyg field. I’m considering talking directly to Elliot about this and see if there’s a deeper reason why he’s not using the default wp_editor function or if it’s something that could be introduced in an update. I think that would solve most issues people currently have including yours 🙂
Thanks. Do you have any idea in which version of ACF this bug started? This site I’m working on isn’t going live for quite a while (it’s pretty large), but my team is working on smaller sites that will be pushed out the door much sooner. We might need to roll some of those ACF installations back an update or two.
I just updated my WP installation to 4.3 and the ACF WYSIWYG is still acting strange, but a little different than before.
It’s no longer changing the code saved. Whether I’m using paragraph tags, inline, or hard returns, it stays the same. However, it’s still getting rendered to the page oddly. For example, putting everything on one line adds an empty paragraph before my closing shortcodes.
And this may have been buggy before I updated, but I just noticed that I can’t toggle between the visual and text editors. If I click the one that’s turned off, nothing happens. My selection apparently still gets sent to the cookie, though, because if I refresh the page, I’ll see the editor I tried to switch to.
Okay. I’ve notified Elliot of your issue along with a few others so I don’t think there’s much more I can do at this point. I’m not a developer of the plugin you see.
I hope everything will work out for you! And if I may be so bold to advice against extensive use of shortcodes whenever possible.. they tend to be messy and less intuitive 🙂 Of course it’s hard to do if you’re not a developer able to modify or create your theme.
Yeah, I agree that extensive use of shortcodes isn’t the best. I am a developer actually, but my clients are not and want the functionality that the shortcodes provide, so I give it to them. Maybe I should encourage my designers to shy away from laying out example mockup content in a way that would necessitate shortcodes. Hmmm…
Thanks for the help Jonathan!
Actually I think most layouts can be achieved but instead of shortcodes you can work more with page templates and/or flexible field from ACF.
I’ve created a completely modular page layout for a client with up to eight columns of content just by using the flexible field and they love it!
Big + that they don’t need to worry about shortcodes in their content either.
The big issue with all the screenshots above was happening before WP 4.3 and ACF 5.3.0. I noticed the editor toggle bug after updating to WP 4.3, but that got fixed with the ACF 5.3.0 update.
I ran the same three tests from earlier after updating everything, and though the code in the ACF editor no longer changes, empty paragraphs still get rendered to the page. Putting the shortcodes and paragraphs on their own lines like in my first example renders empty paragraphs before and after my content. Putting everything inline (2nd test) still renders an empty paragraph after my content. The third test with hard returns and no paragraph tags in the editor at all puts a line break at the beginning, my first block of content without any wrapping tags, an empty paragraph tag, then my second block of content in paragraph tags – http://grab.by/JNuS.
Thanks for the idea @jonathan. I’ll consider that, but there are other shortcodes in this plugin that are very useful like tabbed content and accordions/spoilers.
Given that this thread and problem is so old already (and had been reported before), did anyone come up with a solution? I have developed a very basic columns shortcode based on flexbox, and though I can hide empty paragraphs with CSS, it’s still a bit risky and not very beautiful to have trash in the code :).
Would love to hear from someone possibly having cracked this thing :).
The topic ‘Wrapping shortcodes with paragraph tags’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We are currently experiencing an issue with our hosting and our site is down. 😅— Advanced Custom Fields (@wp_acf) September 21, 2021
Apologies for the inconvenience, we'll keep you posted! ^IP
© 2021 Advanced Custom Fields. Subscribe