WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
The [embed] shortcode removes all shortcodes, runs alone, and then lets everyone else run through. core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/…, + check this codeseekah.com/2012/02/26/what-the_content-goes-through on what filters are usually applied, wpautop may not be the only reason. – soulseekah Mar 21 '12 at 12:03
up vote 2 down vote accepted

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);
share|improve this answer
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 – Dean Elliott Mar 21 '12 at 12:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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