Remove extra line breaks in WordPress

December 29th, 2003

This is for me to remember, but can be useful to others as well. It took me almost a half hour to hunt down and I dont want to have to hunt it down again!
Find this line in your b2functions.php (inside your b2-include folder):
function wpautop($pee, $br=1) {

Replace it with:
function wpautop($pee, $br=0) {

And no more extra line breaks!




  1. paul (1 comments.) says:

    This function makes it impossible to display multiple images next to each other in a post, as it inserts line breaks in between each one. This fixed the problem, I’m really glad you found it, I was looking for it for a while and couldn’t find it.

    It took me a while to find your post also, I was looking for something to do with line breaks and img tags, I didn’t realize that this one massive function handles all of this stuff.

    The only difference now is that it’s now in functions-formatting.php inside the wp-includes (in wp mingus).

  2. Jack Po (1 comments.) says:

    This post is definitely most useful. I was having an issue where kept showing up in my posts when I was doing a (using plugin exec_php) and this completely solved the problem.

  3. gabe (1 comments.) says:

    is this something that can be updated for the latest version of wordpress – I can’t seem to find the
    function wpautop($pee, $br=1) string in order to replace it – wordpress seems to want to delete all of my and tags plus puts in extra spaces in the wysiwyg interface in order to have a valid tag – any help is greatly appreciated. I’m running the TinyMCE advanced.

  4. Mati (2 comments.) says:

    I am running WP 2.7.1 and needed to remove extra line breaks after images…
    So I applied this change from $br=1 to $br=0
    But now all the content is just one long line of text…
    Even where the WYSIWYG editor shows the lines with te correct formatting, still the text in the post is displayed flat..
    Any idea how to solve this?

    • Mati (2 comments.) says:

      ok, I found the solution!
      I still use $br = 1.
      I changed the definition of $allblocks in wpautop function (defined in wp-includes/formatting.php).
      I removed the “input” from the expression, and now I don’t have any extra line breaks before this tag (I guess this can be done for any of the tags defined there)


  1. Line Breaks
    Wrestling with legacy linebreaks from Blogger and MovableType in WordPress 1.2.

  2. […] Remove extra line breaks in WordPress […]

Obviously Powered by WordPress. © 2003-2013

page counter