1

In WP post editor, how can I change lines without adding an empty line?

I try to post this

One line
Second line
third line

But it always shows like this

One line

Second line

Third line

PS: I don't want to completely remove wpautop, because it will probably ruin all my previous posts.

  • 2
    Every time you type "enter" (the return character) the editor creates a new paragraph "<p>my content</p>" , the alternative is to type shift + enter so that the editor creates a line break instead "<br/>" – gdaniel Dec 16 '15 at 22:34
  • Thanks! Is it possible to show the <br/> in the code? – IXN Dec 16 '15 at 22:54
  • 1
    Or alter the CSS that formats paragraphs... – s_ha_dum Dec 16 '15 at 22:56
  • 1
    If you want more information on what @gdaniel said, search for "soft return", that´s what it´s called. – flomei Dec 17 '15 at 15:30
  • 1
    @ixn I don't think you will be able to see the <br/> on the "View" tab, but maybe on the "Text" tab? If not, there might a plugin out there that does it. But that's the default behavior of the wp editor and many other editors out there. – gdaniel Dec 17 '15 at 16:23
1

gdaniel answered the bulk of question with this comment:

Every time you type Enter (the return character) the editor creates a new paragraph <p>my content</p>, the alternative is to type Shift+Enter so that the editor creates a line break (<br/>) instead.

Note that the the <br /> and </p> tags are added via wpautop, one of the display filters attached to the wp_content filter.

Thewp_content filter is not applied to the content being viewed within the Text editor, so the <br /> and </p> tags added by wpautop are not visible there. Instead, the raw text is displayed so the formatting is just a result of any newlines being present:

Soft return
Soft return
Soft return

Normal return

Normal return

Normal return

The Visual editor does not show HTML tags, but the browser's developer tools can be used to inspect the Visual editor's HTML content, where the above would be rendered as:

<p>Soft return<br>
Soft return<br>
Soft return</p>
<p>Normal return</p>
<p>Normal return</p>
<p>Normal return</p>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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