Solved

How to Stop WordPress from Removing Paragraph <p> Tags From Editor?

Posted on 2014-04-07
4
12,389 Views
Last Modified: 2014-04-07
How do I stop WordPress from removing paragraph tags (<p> and </p>) from the post/page editor? I often copy and paste HTML code from a post or page, edit it in another text or HTML editor, then use the resulting HTML code elsewhere in other applications that do require <p>...</p> tags around paragraphs, not just line breaks.

Please let me know your thoughts. Any and all ideas and solutions are appreciated. Thanks in advance for your help!
0
Comment
Question by:simdex
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39983950
Paste HTML code in the "Text" tab of the editor.
You'll see there the HTML structure of your page/post.

HTH,
Dan
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 39983964
There are a couple of different ways.  

One is to use a slightly different editor:

http://wordpress.org/plugins/tinymce-advanced/

That plugin replaces the default editor with a more configurable version and one of the options will be to preserve your HTML.  

The other way is to disable the function that performs the removal.  This is as simple as adding the following to your functions.php file:

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

Open in new window


Ref: https://codex.wordpress.org/Function_Reference/wpautop

Yet another way is to use this plugin to enable/disable the filters on a per post/page basis:

http://wordpress.org/plugins/wpautop-control/
0
 

Author Comment

by:simdex
ID: 39983972
That doesn't address my question. I don't want WordPress to remove the <p> tags from the text/code editor ever.  WordPress by default treats regular line breaks as cue to start a new paragraph (I'm not talking about <br> tags). I don't want this.

Please let me know your thoughts at your convenience.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39983973
You'll see there the HTML structure of your page/post.

Dan, FYI:

Unless you disable wpautop() your solution won't work. Pasting the text, then switching to visual mode and/or publishing will strip the p tags.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now