Archive for February 2011

WordPress has a tendency to sprinkle an abundance of p tags in your blog posts wherever you have lots of spaces between paragraphs. In most cases it is exactly what you want. You want the paragraph spacing to be nice and consistent. But there are times it works against you. I tend to put all code extracts in my blog posts in code tags. I use css to style any code that should be a block. The problem is code tends to have consecutive line breaks. Wodpress goes and separates the codeblock where it finds more than one line-break and wraps them in a p element.

So, what do you do? Well, the solution is the wp-includes/formatting.php in a function called wpautop(). Apart from finding a whole bunch of pee jokes in this function (with variable names like pee and tinkle), you will see that it cleans up line breaks and replaces a lot of them with P tags. You will also see that pre tags are treated specially.
Keep reading »