1. works!
    thank you!

  2. Beautiful! Why isn’t this in WordPress.org’s documentation? Your solution works far better than the 20 other pages I read while researching this issue.

    Thank you much for sharing it!

  3. Thanks. Your solution makes total sense! All the others seem to be a half solution, and you provide the full solution!

    Thank you

  4. You are a genius. Thank you loads for sharing this, the most useful WP tip in ages.

  5. Wonderful !

    I was worried I’d have to clone/recode plugins to get my site compliant, but this is a far more elegant solution.
    Thank you, Phil.

  6. anachnus
    · Reply

    thank you!! 😀

  7. All the solutions I’ve seen so far either complete remove autop functionality from all shortcodes or remove the ability to intentionally add br and p tags between the shortcodes.

    The key is to recreate the wpautop function with the ability to specify shortcodes that it should not run the filter on.

    I don’t mean to self promote but I’m not sure of another way to share the code as it is quite long.

    I did so here:

  8. Chris
    · Reply

    Dude you rule… I was scratching my head on this for an hour before I came across your post which totally saved the day.

  9. Paolo
    · Reply

    Thank you. This was VERY helpful.

  10. AJ Michels
    · Reply

    We have tried this but now all of the HTML that our Shortcodes generate is being impacted by wpautop. For example. I might have a shortcode that outputs something like

    and I end up with something like this

    Any thoughts? I have been looking all over and finding a lot of people posting solutions that solve one problem but just introduce another.

    1. Hi,

      Sorry – your code got stripped during sanitization, feel free to drop it in a gist if you want to share it.

      Unfortunately this can be hit or miss and there are so many variables including what your theme or other plugins are doing I have found it is always a try it and see problem…
      You could try varying the priority (99) to see if moving it a bit earlier or later helps. Or have a dig through the shortcode code (if they arn’t your own of course). Or lastly try the old faithful of disabling all plugins and using a WP theme (e.g.: TwentySeventeen) and testing it there as it could be a problem introduced by another plugin or theme.

      All the best,

Leave a Reply

Your email address will not be published. Required fields are marked *