Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Steps for problem reproduction:

  1. Open WordPress Admin Dashboard (I use version 3.7);
  2. Click on Page > Add Page;
  3. On the editor, choose the "HTML" Tab;
  4. Write <p>Lorem ipsum dolor sit amet</p><br> on the content area;
  5. Choose the "Visual" Tab;
  6. Choose "HTML" Tab back;
  7. The code <p>Lorem ipsum dolor sit amet</p><br> lost its formatting and appears as:

    Lorem ipsum dolor sit amet
    
    &nbsp;
    

How to deactivate this TinyMCE issue to maintain the entirely original formatting? (I'm looking for a solution on JavaScript client-side of the editor)

share|improve this question

2 Answers 2

Once you save it, the

tags are automatically added to the contents. It only removes it when you have a plain <p>....</p> but if you have <p class='something'>...</p> it would preserve it.

share|improve this answer
    
Hi iSuthan thanks for the answer! Actually, I think this is not a server-side problem, that is, it doesn't matter whether you save the Post/Page or not, for this to happen. The issue seems to be related with the TinyMCE plugin. It seems that it cannot convert Visual to HTML when you switch tabs back. What I want is to totally disable it or fix it in some way. –  João Paulin Oct 29 '13 at 20:39

You can add:

"wpautop" => false

as an argument to your wp_editor.

Example (mileage may vary) :

 $args = array(
                "textarea_name" => $this->option_name . "[editor_text]", // Name of the textarea on the forms, this value is passed when submitting the form.
                "textarea_rows" => 15, // The number of rows textarea displays.
                "wpautop" => false, // So <p> tags are not removed going from text->visual->text in editor.
                "editor_class" => "my_editor_custom_css" // Additional CSS classes added to the TinyMce editor.
            );

        echo wp_editor($display_text, "my_editor_html_id", $args);

Note that you have to use <p> </p> tags rather than <br> but that is the preferred way nowadays anyway since it gives you the capability of formatting with css without touching the html.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.