Tell WordPress to stop adding paragraphs tags automatically

WordPress is designed in such a way that it will help you save time doing a lot of different things while you write your blog. Many of those things are done automatically and you don’t even have to know what’s happening behind the curtains. But when you get more into it and you start customizing your own WordPress to make it better for your website, you will find many of those things are unnecessary. Not only you won’t be needing some of the functions, but they might be a distraction.

One example is definitely the wpautop function. This function tells WordPress to automatically create paragraph tags wherever you have used double line-brakes. WordPress does that automatically for your content and excerpts.

Even though you won’t see the tags in your editor, after you hit your enter key twice, WordPress will assume you wanted a <p></p> tags to be inserted. While this can be a good thing if you really want paragraph tags there, it might mess up your website layout in certain occasions. So, why would you delete paragraph tags every time you’re posting something or be careful with your double line-breaks when you can easily turn the function off? In this article, we’re about to show you how easily you can do that.

Stop creating paragraphs automatically:

  1. Open functions.php file
  2. Copy and paste the following code:
  3. remove_filter( 'the_content', 'wpautop' );
    remove_filter('the_excerpt', 'wpautop');
  4. Save changes

As you can see in the code, you can remove the filter separately for the content and the excerpt. That means you can use only the first line if you want to remove automatic insertion of the <p> tag for the content, i.e. for the excerpt.

Remove automatic paragraphs in custom post types:

If you want to remove the filter for your custom post type, you will need a bit different code in your functions.php:

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

Don’t forget to change the ‘custom_post_slug’ to your own custom post slug, save changes and you’re done.

Start Blog Book


This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *