Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 18761
  • Last Modified:

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

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
simdex
Asked:
simdex
  • 2
1 Solution
 
Dan CraciunIT ConsultantCommented:
Paste HTML code in the "Text" tab of the editor.
You'll see there the HTML structure of your page/post.

HTH,
Dan
0
 
Jason C. LevineNo oneCommented:
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
 
simdexAuthor Commented:
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
 
Jason C. LevineNo oneCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now