Disable Automatic Insert Of p, br Tags In Posts In WordPress

WordPress automatically inserts <p> </p> and <br /> tags in the “Text” section in your posts and pages. When you are writing any codes or in some situations it becomes very annoying when you get <p> </p> and <br /> tags automatically filled in your posts. To disable this feature, open the functions.php file of your WordPress theme. Add the below given lines of code:

remove_filter( ‘the_content’, ‘wpautop’ );
remove_filter( ‘the_excerpt’, ‘wpautop’ );

That’s it. WordPress will not automatically put <p> </p> and <br /> tags in your posts and pages.

Note: If you are still facing the same problem, even after you made the above changes. Simply trash the post which you were working on and create a new one. That will solve it.

Download thousands of Themes, Plugins & Graphics to create your Website. Use promo code ThatsJournal and get an additional 10% off for All MonsterONE Plans.
Disclosure: Thats Journal is supported by our readers. This page may contain affiliate links. That means, if you click on these links to make a purchase, we may earn a small commission (at no extra cost to you). These funds help us to keep this blog up and running.

4 thoughts on “Disable Automatic Insert Of p, br Tags In Posts In WordPress”

  1. Yup, that solution works, but removes all paragraphs entirely from the site – even if on some pages / posts you need them. Any suggestions on toggling this feature for specific pages / posts?

    The reason I ask is we need the auto p function removed for literally one page because it’s breaking some javascript code. All of the other pages where is inserted is fine.

    TIA!

      1. Yea, I’d definitely say out of all of the plugins I’ve tried, that one is the best. Another suggestion I got from a developer that works on other themes is if none of the other plugins work, just try custom coding it into functions.php, like this:

        function remove_p_on_pages() {
        if ( is_page() ) {
        remove_filter( ‘the_content’, ‘wpautop’ );
        remove_filter( ‘the_excerpt’, ‘wpautop’ );
        }
        }
        add_action( ‘wp_head’, ‘remove_p_on_pages’ );

        …this way the page looks through the check in the section first before the WP filters take effect, in this case by seeing if the document is a page or not, and if it is, run the filter.

        Unfortunately I had to get stuck with a buggy theme and had to email the devs on this one because nothing works, but hopefully they can help. Thank you too for your comments and for the post, you helped me on the right track!

Comments are closed.