How to Stop Wordpress From Adding <br /> Tags?

December 26th, 2009 • No Comments • Blogging, Tutorial

Recently I created my first theme for WordPress and after a fresh install I was eager to start writing my first post. Guess what happened? An odd <br /> tag kept appearing every time I jump a line with the Enter key.

After spending a fair amount of time looking at every corner of the WordPress back-end looking for a stop-adding-br-tags option without success, I did some research on the WordPress Help Center and confirmed the obvious, there is no such option.

Since my tweaking knowledge of WordPress is still limited, I was hoping that someone else had already found the solution. A few keywords later I hit Simon Battersby Blog that presented a relatively painless solution. Simon has found a variable inside the “formatting.php” file which allows you to turn off this annoying feature.

To fix this, download “formatting.php” from your server and search for the function “wpautop” in your text editor. You will find this:

function wpautop($pee, $br = 1)

Change it to this:

function wpautop($pee, $br = 0)

Then save the file, publish it back to your server and presto, no more annoying
tags! Works fine in WordPress version 2.9, but remember to change again if you update WordPress since it will restore the file to the original setting.