Solved

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

Posted on 2014-04-07
4
11,644 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

762 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

13 Experts available now in Live!

Get 1:1 Help Now