Home Forums Bug Reports Wrapping shortcodes with paragraph tags


Wrapping shortcodes with paragraph tags

  • 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.

  • Hi @j2trumpet

    So just to be sure this isn’t a regular issue in WP, the same does not occur when using the standard editor?

  • 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.

    Same content in both originally –
    How content is saved after hitting publish/update –

    Original with all tags/shortcodes inline –
    After updating –

    Original with hard returns –
    After updating –

  • 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?

  • I’m running WP 4.2.4 and ACF Pro 5.2.9.

    I’ve got a couple ACF options pages, but that’s it. No additional hooks or filters.

    I’m using the Shortcodes Ultimate plugin to generate the shortcodes you see in my screenshots.

  • Hi @j2trumpet

    Okay thanks for the info!
    It would seem like this might be a bug in ACF but just to make sure is it possible for you to deactivate all other plugins?

  • I just tried turning everything off except ACF and got the same results.

  • Alright thanks.

    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.

  • Hi John,

    Unfortunately no.. I’m not that deeply involved with the ACF development.
    However you might look at the changelogs and search for references to wysiwyg.

  • 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.

  • Hi John,

    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.

    Good luck!

  • 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!

  • Hi @j2trumpet

    Thanks for the bug report.

    Did this issue start after upgrading to WP 4.3?
    There have been some recent changes to the editor, and I wonder if upgrading to ACF PRO 5.3.0 may help.

    Let me know, and I’ll do some replication to figure out the issue

  • @j2trumpet

    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.

  • Hi @elliot,

    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 –

    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 :).

  • Hey – I arrived here from duckduckgo, and am looking for a way to deal with this issue.

    I hate that shortcodes always have <p> tags everywhere around them when using an ACF wysiwyg field.

    Any updates?

  • You should contact support if you are having this issue. I think it’s an ongoing problem with shortcodes, not only in ACF fields but in WP in general.

Viewing 19 posts - 1 through 19 (of 19 total)

The topic ‘Wrapping shortcodes with paragraph tags’ is closed to new replies.