WordPress.org

Ready to get started?Download WordPress

Forums

Getting shortcodes with content to play nice with wpautop (2 posts)

  1. automaton
    Member
    Posted 2 years ago #

    I've spent about half a day figuring this out, so I thought I'd share this rather simple solution.
    I have a shortcode with content ([kvl_inset]content[/kvl_inset]) that was causing problems with wpautop. The shortcode is replaced by an <aside> block, but depending on the context, there would either be a stray </p> or <p> in the output of the_content(), or the opening or closing <aside> would be wrapped in a paragraph tag.
    Apparently, this is because the wpautop filter is run before the shortcodes filter, which messes up tag nesting.
    The rather simple solution that solved it for me was to change the priority of wpautop in functions.php, like this:
    add_filter( 'the_content', 'wpautop',20 );

  2. Baden
    Member
    Posted 2 years ago #

    Wow, I have been looking for a quick-fix like this for months! Thank you... it worked on this end.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags