2

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

-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 that you have read and understand our privacy policy and code of conduct.

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