Stop auto formatting in shortcodes

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.

Read More

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

Related posts

Leave a Reply

1 comment

  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);