| Subcribe via RSS

Disable Automated Line Breaks in WordPress – wpautop

May 12th, 2009 | 1 Comment | Posted in WordPress

Sweet Jesus this was way harder than it should have been. So I’ve been using Alex Gorbatchev’s SyntaxHighlighter (highly recommended to all the blogging coders out there by the way) to make my code look all pretty — preserve tab spacing, notch line numbers, color code everything nicely. It worked great except for one thing. Whenever I would have a line break it would insert a <br> tag following the line which would subsequently annoyingly show up in my code. It didn’t matter if the enter was hit in the WYSIWYG or in the HTML view, they always got added. It became a tad bit infuriating because nothing I did would stop this madness.

After much research, I discovered that WordPress has a function called wpautop which formats the page at runtime and inserts these unwanted tags all over the place. Its a great feature for the non-programmers out there, but there should be an easy way to shut it off for the rest of us. Thankfully for my sanity and yours, Urban Giraffe has created a plug-in that will disable wpautop. I tossed it into the mix, and it worked like a charm. The only GOTCHA is the logical one. WordPress isn’t going behind you to clean up your formatting mess anymore so you’ll need to start adding the appropriate break and paragraph tags where needed. With that said, if you have a blog with hundreds…thousands of posts that haven’t been formatted properly, you may want to think long and hard to determine if its worth the extra effort its going to take to reformat all those posts.

Tags: , ,