The wpautop is a codec of WordPress which is used to format posts automatically. When WordPress displays a post’s contents it passes through several filters that ensure it is displayed in a proper manner similar to the way you entered it in the editor.
If you normally work on the visual (or the WYSIWYG) editor, this function would not be much of a bother for you. It would pose problems generally for those who use the HTML editor for writing their content.
What wpautop Does
wpautop is a filter which works on the_content and the_excerpt tags. It converts double line breaks into paragraphs automatically when you work in the Text (or HTML) mode. It replaces double line breaks with
<p>Your content</p> and single line breaks with
By doing this, it helps avoid potential problems and confusions that might have otherwise crept into the editor.
However, this filter might cause some issues when you are inputting a lot of HTML markup in the post editor. Also, it can give rise to further hassles when you are trying to insert a shortcode. wpautop will insert a paragraph and a line break tag every time you insert a new line and the result would be that you would get text instead of the shortcode you desired.
Situations like these make it necessary to disable the functioning of wpautop. Here we show you how to disable wpautop.
How to Disable wpautop
wpautop is by default enabled for all WordPress installs. Though it is a fairly easy step to disable wpautop. You just have to make sure that your content doesn’t pass through this filter. You do that by entering the following line to your functions.php file.
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
That’s it! You won’t have unnecessary paragraph and line breaks in your content and excerpts now.
In case you wish to enable wpautop again, you can simply delete the code you entered from functions.php file and you’ll have it working again.