WordPress automatically adds paragraph (p) tags to text that is entered in the post editor. However, if you enter double line breaks between paragraphs, WordPress will create an extra empty paragraph tag. This can cause formatting issues and unwanted extra spacing between paragraphs.
Disabling double line breaks with paragraph elements in WordPress can help ensure that your paragraphs are displayed correctly and that there is no extra spacing between them.
To disable double line breaks with paragraph elements in WordPress, you can use a filter to remove the extra paragraph tags that are created when double line breaks are used.
The wpautop()
function adds <p>
and <br>
tags to your content in order to preserve line breaks.
If you want to Disable double line breaks with paragraph elements then just add below code to your theme’s functions.php file.
remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); function aiooc_crunchify_wpautop_nobr( $content ) { return wpautop( $content, false ); } add_filter( 'the_content', 'aiooc_crunchify_wpautop_nobr' ); add_filter( 'the_excerpt', 'aiooc_crunchify_wpautop_nobr' );
This code will remove the default WordPress filter that adds paragraph tags to content, and replace it with a new filter that adds paragraph tags without extra line breaks. This will ensure that paragraphs are formatted correctly and will not include extra spacing or unwanted empty paragraph tags.
It is worth noting that disabling double line breaks with paragraph elements may affect the formatting of some themes or plugins that rely on this functionality. Therefore, it’s important to test your website thoroughly after making this change to ensure that everything is working correctly.
Is there any other way to disable wpautop in WordPress using Plugin?
Yes.
- Just download plugin Crunchy Booster.
- Go to
AIO Optimizer
->WP-Admin Tweaks
page. - Enable toggle: Disable double line breaks with paragraph elements.
That’s it and you are all set.
Crunchy Booster is the Simplest WordPress Optimizer & Customizer Plugin!
It provides simplest, light weight, most powerful All-in-One 50+ Optimization
, Customization, Webmaster, Database, Configuration, WordPress fine-tuning options in single plugin.