Removing extra p and line breaks from shortcodes in WordPress

Some time shortcodes add some some extra <p> and <br /> after of before post.This is happend because of the wpautop filter.

You can easily prevent this by changing the execution priority of wpautop filter.

Simply use this code on your theme functions.php

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
2 replies
  1. Michael
    Michael says:

    I did not work…..
    I added this into the functions.php and tested it. did not work.
    Then I added it into the admin-shortcodes.php file and tested it. did not work.


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply