WordPress Line Break Problem

Yesterday I installed a fresh copy of WordPress on a subdomain of this site. I used Fantastico’s autoinstall feature, so I got the WP 2.2.2 version. I left the visual editor enabled because I was feeling lazy. Today was writing a post using that new WP install and noticed that some lines where wrapping at strange places. After saving the draft I viewed the post in different browsers and verified that the unusual line breaks were visible outside of the visual editor, too.

There were no extraneus <br> or <p> tags in the HTML code and – after a lot of tinkering – I concluded that the theme/CSS was fine, too. Searching Google for “WordPress line break problem” turned up a number of pages, but none of them dealt with the exact problem I had (looks like WP has had lots of other line-break related issues). My “programmer’s intuition” hinted that the problem might actually stem from page encoding/character set bugs.

Long story short, it turned out that some the spaces in my post were Unicode spaces while some were… of some other kind. For some reason this causes web browser(s) to do strange word wrapping.

What I did was this :

  1. Turn off the visual editor.
  2. Edit the post.
  3. Copy all the contents to Notepad.
  4. In Notepad, select one space and copy it (Ctrl+C).
  5. Edit -> Replace…, paste the copied space in the first box and type a normal space in the other box.
  6. Hit Replace All.
  7. Copy the text back to the post and save.

I also applied a charset encoding hack to my wp-config.php. All this combined solved my line break problem.

Related posts :

4 Responses to “WordPress Line Break Problem”

  1. Nestor says:

    I’m having a line wrap problem with a page right now, and it seems like it’s doing the line wrap based on the length of the html source and not the resulting rendered html, so a paragraph with several links is full of linebreaks. It’s annoying.

  2. White Shadow says:

    You might try the Raw HTML. Maybe applying it to the incorrectly wrapping text would help.

  3. Rene says:

    I have the same problem too, only I have hundreds of pages that have the problem. I’ve been importing the code from a previously created site that doesn’t have this problem.

Leave a Reply