Plugin to stop WordPress adding <br/> tags
Quite a while ago I wrote a blog post about stopping WordPress adding <br/> into your posts, a particularly irritating habit. The solution I posted involved editing the function wpautop() in formatting.php, specifically changing this:
function wpautop($pee, $br = 1)
to this:
function wpautop($pee, $br = 0)
Now, this works fine, but whenever you upload a new version of WordPress, the change gets overridden and you have to do it again. If you’re interested, here’s the detail. wpautop() most noticeably adds <p> tags around (what it thinks are) paragraphs, as well as adding the <br/> and a host of other formatting stuff. It’s easy enough to get rid of the function altogether via:
remove_filter('the_content','wpautop');
However, I didn’t want to disable the paragraph formatting, particularly on a site for a client, just sort the <br/>. So here’s the whole plugin code:
<?php
/*
Plugin Name: Better wpautop
Plugin URI: http://www.simonbattersby.com/blog/plugin-to-stop-wordpress-adding-br-tags/
Description: Amend the wpautop filter to stop wordpress doing its own thing
Version: 1.0
Author: Simon Battersby
Author URI: http://www.simonbattersby.com
*/
function better_wpautop($pee){
return wpautop($pee,$br=0);
}
remove_filter('the_content','wpautop');
add_filter('the_content','better_wpautop');
?>
All I'm doing is defining a function better_wpautop() which calls the existing function, setting the $br variable to 0
Feel free to use this. It'd be great to know if it works for you so leave me a note below. To add as a plugin, download the zip file, unzip in your plugins folder and activate via the admin panel

Thanks for this. I put the code in my functions.php file and it work perfectly. I appreciate it.
thanks. solved in two minutes a problem I might have taken hours to find and fix (also – thanks JG @1 – I also just dumped the code in functions.php)
Thanks! This was driving me crazy! I’m running WP 3.1.4
Now that I have installed Better Wpautop, I realized that the visual editor is stripping our paragraphs and line breaks. Is there a suggested change to fix the visual editor?
The WP visual editor does fight back, yes. I have mine disabled completely, but if this isn’t an option, I’m not clued up on any fixes I’m afraid.
AWESOME!! Fixed it for me too, I added the code to functions.php and it works perfectly! Thank you
– WP3.2.1
Worked wonders for me, thanks for posting this solution!
- WordPress 3.2.1
It worked! I think this solves a big issue for me. Thank you!
Thanks a lot for this! Just learning about WordPress and this was really pissing me off as well!!
Is this still working with WP 3.3.1? I included it in my theme’s function.php and so far I don’t see any difference…
Yes, just tested it and it works fine.
I have diable visual editor plugin enabled and visual editor turned OFF AND using this plugin and still it adds BR to my posts why?
It is because this only work WITH the visual editor ON
Hi Bron
It works OK with the visual editor disabled. I use this approach myself, but just have visual editor disabled against my user, rather than via a plugin.
You could try adding the code to your theme’s functions.php and see if that works for you. Possibly something in your visual editor disabling plugin is interfering.
I am using WordPress version 3.3.1 and i tried this hack and it did not work for me. Is it just me or someone also getting this problem?
It works fine for me in 3.3.1 – previous commenter Sophie also got it working OK.
This works great! 3.3.1. WP added 10 br tags to every page I created.
I added this (including your credits) into my functions.php file and it works perfectly.
Thank you very much for publishing a simple solution to a problem that has been bugging a lot of people for a very long time.