Skip to content

DAK: How to manually insert a <br /> into a post's code, and NOT have wordpress remove it?

This problem has been annoying me for AGES! I've tried alternative Text editor replacement plugins, but those usually added other formatting errors that made my posts worse. All I want is a way to add a <br /> and make it STAY PUT without WP stripping them out of my posts. Anyone know the best way to do this?

EDIT: I want to add more than one <br />, so a SECOND break, right in a row to add additional spacing in my blog.

Edited 7 Oct 2010. We only hold this version.

10 points22 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
10 · 100% up
Kind
Text
ID
doadv

Author

33
posts
33
comments
3
media
View profile

22 comments

I use a plugin called TinyMCE advanced. It adds some more functions to the editor and has an option to keep breaks.

3 points

I tried TinyMCE (and other editors) but they caused other issues at the time. I'm hoping to still use the built-in editor, thanks though.

1 points

If you know php (and wordpress) and you only need to keep the br tags, it wouldn't be too hard to write a hook to your theme's function.php.

Try wordpress stack excange or the wordpress.org forums, it won't be hard for someone familiar with the inner workings of wp.

1 points

Me to. It's pretty annoying WP deletes them.

1 points

I'm assuming you're concerned with getting a line break instead of a paragraph break, and not the specific insertion of your <br />.

If that's the case, just type/paste that content into HTML view. When you go back to Visual editing the spacing you put in code view will stay. This is by far the easiest solution I know to what I think of as the poetry problem.

As to manually inserting <br />s, I have no real experience, but HTML view usually seems to maintain formatting pretty well for me.

1 points

Yes, a line break. I've tried editing the content in both HTML and Visual modes, and any extra line breaks will be removed by Wordpress without fail, if there is more than 1 break consecutively.

1 points

Oh, so you're trying to do more than one linebreak at once. I could believe that WordPress's parser just tears that to bits.

1 points

Have you tried Windows Live Writer? The new version works perfectly with Wordpress (even self-hosted) and is more robust and faster than the visual editor in WP.

1 points

I haven't tried Live Writer with Wordpress, but I'll check it out!

1 points

I'd be interested in Live Writer but their website is god awful and gives no useful information whatsoever.

1 points

In your user options, you can simply turn off the visual editor. I think there's an option in there to not correct what it's calling malformed tags.

1 points

See, I want to use the visual editor, I just want an extra line break when I tell it to add one, without it taking the extra break out.

1 points

Try adding a bunch of these... <br /> 

1 points

I could have sworn WP removed the <br />'s the last time I tried adding anything after it... but I'll try this again.

1 points

I agree this is super , super annoying.

One of the tricks that seems to work even though it's kind of dumb is entering <code> </code>

1 points

I haven't tried that one, I'll try it next time.

1 points

I don't understand.

One of WP's core filters called wpautop should do this autoamtically. You shouldn't need to manually add line break or paragraph tags.

In WP's non-visual editor, wpautop adds a paragraph tag for every two line break characters (\n\n) and a break tag for a single line break character (\n).

If you're putting a lot of HTML in your post/page content then you really ought to be using custom templates instead.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.