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

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

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

shordcode call:

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

what ends up being rendered:

<span data-html="


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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.