[box id='1' text="some texte"]

the shortcode, at one point is outputting text

the html result is : </p> some text </p>

There is an extra closing paragraph in the start and and opening at the end... WHY ?

where those come from ?.... any idea ?.. it screw my w3 validation !

** note i have found that... but look all "patched" to me...any clean solution... wp is dirty ? reference

4 Answers 4


I discover that it's a know bug, and will be fix in future release Reference here So then, i used this code... not pretty, but do the magic !, thanks

$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr( $content, strlen( $content ) - 3 ) )
    $content = substr( $content, 4, strlen( $content ) - 7 );
return '<div my stuff>' . $content . '</div>';
  • menardmam, <p> still remains - how to remove it?
    – user20303
    Sep 11, 2012 at 21:45

I had the same problem and checked the $content in the add_filter() function. There you can see what happen with the shortcodes. I ended up with an easy plugin, that removes silly p and br tags on shortcodes: http://www.johannheyne.de/wordpress/shortcode-empty-paragraph-fix/


Make sure there is a double line-break before and after the shortcode in the editor;

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sodales, neque vitae imperdiet aliquet, elit tortor egestas dui, vel fermentum neque est eu est.

[box id='1' text="some texte"]

Lorem ipsum dolor sit amet...

  • does not change anything.... or just add : # </p> # <p>&nbsp;</p>
    – menardmam
    Mar 16, 2011 at 9:28

When using a shortcode in the block editor, I had a really hard time removing extra p tags until I used the "Custom HTML" block and inserted the shortcode in there.

Hope this helps someone out there like me.

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.