Disable automatic paragraphs in WordPress posts

An easy way to disable automatic adding of paragraph tags in WordPress posts without using any plugins. Disable it completely or for custom post types.

WordPress automatically adds paragraph tags (<p>) in the posts wherever it notices double line-breaks. For example, if you write one line and press the return key twice, it considers you want to add a paragraph there, and then suitable tags will be added when you publish or preview the post.

Auto paragraphs added by wpautop()

You don’t see the tags added in the post editor, but they will show up in the markup when you view the source of your post.

The same thing happens with the WordPress image captions when your insert media right from the ‘Insert Media’ dialog. You may see the same thing happening with couple of more things in WordPress.

This automatic feature is quite handy as it saves you from adding paragraph tags or selecting the paragraph option again-and-again in the Visual mode. But you may want to turn it off, I don’t really know your reason to do that, but I did that to show the demo pages properly.


WordPress function wpautop(); (see at Codex) is responsible for adding paragraph HTML across the ends of your text followed by 2 line-breaks. To avoid auto <p>s, we have to stop this function from doing this.

Provided that you have your reason to turn auto paragraphs in WordPress completely, here’s the single line of code you’ve to add in the functions.php file of your theme and then save it:

remove_filter( 'the_content', 'wpautop' );

For excerpts?

A slight change needed to siege wpautop() from modifying the excerpt:

remove_filter('the_excerpt', 'wpautop');

You may simply remove or comment out this line if you’ve changed your mind.

Remove auto paras only for CPTs

If you want to disable it for Custom post type only, add this a-bit-longer code in your theme’s functions.php and save the changes:

add_filter( 'the_content', 'disable_wpautop_cpt', 0 );
function disable_wpautop_cpt( $content ) {
  'your_cpt_slug' === get_post_type() && remove_filter( 'the_content', 'wpautop' );
  return $content;

All you need is to replace your_cpt_slug to your custom post type slug. I hope you found this useful. Let me know if you have any questions regarding above pieces of code.