?
Solved

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

Posted on 2014-04-07
4
Medium Priority
?
17,496 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 35

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

719 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