Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
    
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.