Solved

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

Posted on 2014-04-07
4
14,503 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

733 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