WordPress auto adds p to shortcode parameters

WordPress auto adds p tags around shortcode parameters. Is there any way to stop this ?

function minimum_working_example ( $atts, $content ){
    extract(shortcode_atts(array(
        'html' => '',
    ), $atts));

    return '<span data-html="'.$html.'"></span>';
}

shordcode call:

[min_example html="<ul>stuff</ul>"]

what ends up being rendered:

<span data-html="

<ul>stuff</ul>
<p>"></span>

desired output is something along the lines of:

<span data-html="<ul>stuff</ul>"></span>

1 Answer
1

You need to ensure that your shortcode functions are executed before wpautop by changing its filter priority.

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);

Leave a Comment