Last updated on

What Causes the Automatic P Tags in WordPress?

The BoldGrid Post and Page Builder for WordPress is built on the Classic WordPress Editor, otherwise known as TinyMCE.

The Classic Editor and WordPress Core both run a filter known as wpautop on your content. Most of the time, this is actually what you want to happen. It ensures that the content you’ve entered into your post or page has valid HTML markup. It also makes sure that if you’ve added blank lines to your content that they actually show up that way for your visitors. However, sometimes, especially when you’re using a shortcode that requires you to switch to the Text Editor to modify, this can be a headache.

How Can I Stop wpautop?

Like many things in WordPress, there’s more than one way to fix wpautop depending on what you need to accomplish. We’ll cover a few different ways that you can use to get rid of wpautop.

Disable wpautop on the front-end using a plugin

The easiest way to avoid wpautop is to use a plugin, like the free and popular Toggle wpautop plugin. This plugin will add an option to all of your posts and pages to disable wpautop, or even let you disable it on all posts by default.

Disable wpautop on a single post with a plugin

The biggest benefit of using this plugin is that you can choose which posts to disable wpautop on, since it’s generally a good thing for normal writing. However, this does not solve the problem of automatic paragraph tags when you switch in between the Visual and Text Editor.

Try to Avoid Switching Editors

Another common solution to the wpautop problem is to simply avoid switching in between the two editors. TinyMCE really was designed to only be used with one-or-the-other editor, and wpautop isn’t the only strange behavior that can happen when you switch.

However, in some situations, it’s simply not feasible to stick with the Visual Editor, and it’s no fun working exclusively in the Text Editor.

Use a Code Snippet to Disable wpautop when switching in between editors

If you’re experiencing the problem with automatic p tags in WordPress are being caused by switching between the Visual and Text Editor, you can use a small Code Snippet to disable the wpautop filter when the TinyMCE editor initializes.

If you don’t already have it, install and activate the free Code Snippets plugin, and navigate to Snippets > Add New.

Name your new Code Snippet, and paste the following into the snippet body:

add_filter('tiny_mce_before_init', function($options) {
	$options['wpautop'] = false;
	return $options;

Now you know three different ways to avoid the automatic p tags in WordPress. Let us know if you have any questions in the comment section below!




   200+ Design Templates + 1 Kick-ass SuperTheme
   6 WordPress Plugins + 2 Essential Services

Everything you need to build and manage WordPress websites in one Central place.

4 thoughts on “How to Stop Automatic P and nbsp Tags in WordPress

  1. Thanks for sharing!
    I also added this option:
    $options[‘indent’] = true;

    To make the HTML code more readable.
    Using the snippet I was able to remove the plugin TinyMCE Advanced.

  2. This is doesn’t work for me. I am using the editor in a custom field through toolset, the wpautop is turned off everywhere else but when toolset calls the field. So when I toggle between the text tags it adds the p tags and filters the content. Any suggestions.

    • Hi Jacob,

      I’m sorry to hear you’re having trouble with this. Have you also tried the code snippet method listed towards the bottom the of guide?

Leave a Reply

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