Is there a way I can stop Wordpress auto formatting everything I enter inside a shortcode tag?

A the moment I want to include a h2, a paragraph and another shortcode, but everytime I do Wordpress wraps each different elemnt in p tags.

Is there a way to remove this so I can format each part individually?


1 Answer 1


You can postpone the wp_autop filter which is responsible for wrapping elements in P tags till after shortcodes are rendered:

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
  • This almost worked perfectly apart from the fact it added empty paragraphs between each shortcode. I just used p:empty{display:none} and it looks great now. Thanks a lot Commented Mar 21, 2012 at 12:30

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.