LineBreak Shortcode


Line Breaks

The WordPress content editor is notorious for eating/munching line breaks. This is because of a combination of WordPress functions which run “behind the scenes” whenever saving content or switching between “text” and “visual” views. WordPress will seek out recurring line breaks, and remove them from the editor.

Try for Yourself

To get an idea of what’s going on; create a new post and name it “Test Post”. Next, insert the following content (into the “text” view):

This is my first sentence.
<br />
<br />
<br />
Here is another sentence.

Now, switch between “visual” and “text” views; or simply save the content. You will notice the break tags have disappeared; and the spacing where the break tags existed before has been reduced.

Using the Shortcode

To get around this; WP Edit Pro has created a shortcode which can be used instead. Since WordPress sees this as a shortcode; it has no idea it is really a line break, sneaking it’s way into the content editor.

We use the [break] shortcode whenever we need to insert a line break.

This is my first sentence.
[break]
[break]
[break]
Here is another sentence.

Now the editor will preserve our shortcode whenever saving or switching views. Then, when our content is viewed from the front end of the website; the shortcode will render as a line break in the html code that is output.


Josh Lobe has written 53 articles

Josh Lobe is the sole developer of WP Edit and WP Edit Pro. A father of two; a husband to a beautiful wife; and a small home in the suburbs... he primarily enjoys coding in WordPress and designing websites.

2 thoughts on “LineBreak Shortcode

  1. tim morse says:

    the <pre></pre> set of tags seems to work when placed in the html// at the point where you want the line break. at least it is working right now. I am using the DIVI theme from Elegant Themes.

Leave a Reply

Your email address will not be published. Required fields are marked *

ENTER CAPTCHA MATH *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>