{"id":39764,"date":"2021-06-24T17:55:25","date_gmt":"2021-06-24T21:55:25","guid":{"rendered":"https:\/\/www.boldgrid.com\/support\/?p=39764"},"modified":"2021-06-24T17:56:24","modified_gmt":"2021-06-24T21:56:24","slug":"stop-automatic-p-tags-wordpress","status":"publish","type":"post","link":"https:\/\/www.boldgrid.com\/support\/wordpress-tutorials\/stop-automatic-p-tags-wordpress\/","title":{"rendered":"How to Stop Automatic P and nbsp Tags in WordPress"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><div class=\"video-responsive\"><iframe loading=\"lazy\" title=\"Stop Automatic P and &amp; nbsp code in WordPress\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/IBUSoW8o7Wc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<h2 id=\"what-causes-the-automatic-p-tags-in-wordpress\">What Causes the Automatic P Tags in WordPress?<\/h2>\n<p>The BoldGrid Post and <a href=\"https:\/\/www.boldgrid.com\/wordpress-page-builder-by-boldgrid\/\">Page Builder for WordPress<\/a> is built on the <strong>Classic WordPress Editor<\/strong>, otherwise known as TinyMCE.<\/p>\n<p>The Classic Editor and WordPress Core both run a filter known as <strong>wpautop<\/strong> on your content. Most of the time, this is actually what you want to happen. It ensures that the content you&rsquo;ve entered into your post or page has valid HTML markup. It also makes sure that if you&rsquo;ve added blank lines to your content that they actually show up that way for your visitors. However, sometimes, especially when you&rsquo;re using a <strong>shortcode<\/strong> that requires you to switch to the Text Editor to modify, this can be a headache.<\/p>\n<h2 id=\"how-can-i-stop-wpautop\">How Can I Stop wpautop?<\/h2>\n<p>Like many things in WordPress, there&rsquo;s more than one way to fix wpautop depending on what you need to accomplish. We&rsquo;ll cover a few different ways that you can use to get rid of wpautop.<\/p>\n<h3 id=\"disable-wpautop-on-the-front-end-using-a-plugin\">Disable wpautop on the front-end using a plugin<\/h3>\n<p>The easiest way to avoid wpautop is to use a plugin, like the free and popular <a href=\"https:\/\/wordpress.org\/plugins\/toggle-wpautop\/\" rel=\"noopener\" target=\"_blank\">Toggle wpautop plugin<\/a>. 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.<\/p>\n<p><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2021\/06\/toggle-wpautop.png\" rel=\"lightbox\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2021\/06\/toggle-wpautop-300x285.png\" alt=\"Disable wpautop on a single post with a plugin\" width=\"300\" height=\"285\" class=\"aligncenter size-medium wp-image-39771\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2021\/06\/toggle-wpautop-300x285.png 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2021\/06\/toggle-wpautop.png 622w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The biggest benefit of using this plugin is that you can choose which posts to disable wpautop on, since it&rsquo;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.<\/p>\n<h3 id=\"try-to-avoid-switching-editors\">Try to Avoid Switching Editors<\/h3>\n<p>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&rsquo;t the only strange behavior that can happen when you switch.<\/p>\n<p>However, in some situations, it&rsquo;s simply not feasible to stick with the Visual Editor, and it&rsquo;s no fun working exclusively in the Text Editor.<\/p>\n<h3 id=\"use-a-code-snippet-to-disable-wpautop-when-switching-in-between-editors\">Use a Code Snippet to Disable wpautop when switching in between editors<\/h3>\n<p>If you&rsquo;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 <strong>Code Snippet<\/strong> to disable the wpautop filter when the TinyMCE editor initializes.<\/p>\n<p>If you don&rsquo;t already have it, install and activate the free <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\" rel=\"noopener\" target=\"_blank\">Code Snippets plugin<\/a>, and navigate to <strong>Snippets &gt; Add New<\/strong>.<\/p>\n<p>Name your new Code Snippet, and paste the following into the snippet body:<\/p>\n<pre>\r\nadd_filter('tiny_mce_before_init', function($options) {\r\n\t$options['wpautop'] = false;\r\n\treturn $options;\r\n});\r\n<\/pre>\n<p>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!<\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>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. [&hellip;]<\/p>\n","protected":false},"author":1294,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"bgseo_title":"Stop Automatic P Tags in WordPress","bgseo_description":"Learn 3 ways to avoid the automatic p tags in WordPress from appearing, along with the annoying nbsp characters that also sometimes appear along with them.","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[151],"tags":[],"class_list":["post-39764","post","type-post","status-publish","format-standard","hentry","category-wordpress-tutorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/39764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/users\/1294"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/comments?post=39764"}],"version-history":[{"count":9,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/39764\/revisions"}],"predecessor-version":[{"id":39777,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/39764\/revisions\/39777"}],"wp:attachment":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/media?parent=39764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/categories?post=39764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/tags?post=39764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}