Why are HTML formatting tags being added to my shortcode output? (11 posts)

  1. I just upgraded a client's site to WP 3.4 on the test server and have noticed an issue.

    I have various shortcodes in my functions.php which pull in separate files containing forms. I do this for two reasons: (1) so the form code doesn't get mangled in the editor, and (2) so the forms can be easily reused on various pages.

    This has worked well until the 3.4 upgrade, and is still working fine on the live site, running 3.3.

    For some reason, WP is now inserting various HTML tags such as <p> and <br /> in between the input tags, which is messing up the formatting.

    An example of the shortcode, as well the form code, and the browser source, are here: http://pastebin.com/pQajDntX

    In the browser source version, note all the extraneous <br /> and <p> tags.

    Is there some other ways I should write the shortcode function to avoid this problem? Or is there something else going on?

    Thanks for any suggestions.

    EDIT: Someone on Twitter suggested the following workaround, which actually works:


    The only problem is this means I'd have to go through every single post and page on the site to make the changes - is there something I can do in the function or elsewhere in the theme to have the raw effect applied automatically?

  2. keesiemeijer
    Posted 4 years ago #

    Just thinking out loud, try do_shortcode() in your shortcode.
    [untested (and probably stupid)]:

    return do_shortcode('[raw]'.$otlsignup.'[/raw]');
  3. Not stupid at all - in fact, it works!

    I replaced

    return $otlsignup;


    return do_shortcode('[raw]'.$otlsignup.'[/raw]');

    ...and the extra formatting disappeared.

    Thank you so much!!!

  4. keesiemeijer
    Posted 4 years ago #

    You're welcome.
    And thank you for learning about the shortcode [raw] which I have never heard of before.

  5. And thank you for learning about the shortcode [raw] which I have never heard of before.

    It was my first time hearing about it, too!

    I'm going to leave this unresolved because I'm still wondering why this behaviour changed with WP 3.4 and whether it's a bug - perhaps someone will still chime in.

  6. fitzpatrick512
    Posted 4 years ago #

    Hmm... is there something I need to do to add the "raw" shortcode to my theme?

    When I add the raw shortcode it just outputs [raw] + my shortcode function with extra <p> and
    tags + [/raw]


  7. fitzpatrick512 - not sure why yours isn't working. Maybe paste the whole function into a Pastebin so people can take a look?

  8. Interesting - I just checked the site where I'd applied the [raw] fix, and lo and behold - in some places, it's working fine, and in others, the words [raw] [/raw] are being displayed on-screen.

    I'm not sure why it's working in one place and not in another.

    EDIT - in the places where [raw] is being displayed on-screen, the function is working correction - i.e. no added <p> or <br> markup

  9. fitzpatrick512
    Posted 4 years ago #

    The shortcode I'm having issues with in particular is the Mailchimp widget shortcode. However it's also showing up a few other places, I don't use shortcodes very often though.

    Surely other users are having these issues, I'm surprised there isn't more talk of this on w.org

  10. fitzpatrick512
    Posted 4 years ago #

    In any case, these [raw] solutions require users to modify all the shortcodes on their site, either the shortcode function code or adding it in line...seems quite pain to me. What did WP add in 3.4.1 to cause this I wonder? Would be best to find the source and nip it in the bud.

  11. I agree, it would be best to get to the root of the problem. Seems to have started in 3.4, at least for me. I'll see if I can get the attention of some other folks.

Topic Closed

This topic has been closed to new replies.

About this Topic