Removing First Paragraph Break

WordPress Version: Only Tested in 3.3 and UP

First off, we all know that wordpress has some issues when it comes to automatically formatting our posts’ and that it drives us all crazy! I’ve searched high and low for solutions that are mainly about the wpautop function, which automatically inserts paragraph breaks, usually in the incorrect location.

So in this tutorial, I will show you how to remove the space between your header and your content once in for all.

We’ll be going from this:

to this:

First off, we need to talk about exactly what causes the extra break and what exactly is wpautop and it’s main function. According to WordPress, it changes double line-breaks in the text into HTML paragraphs and filters the_content tag. So basically, all it does is automatically format your post or page by adding paragraph breaks in where it thinks it should be.

Now you could completely avoid it, and disable wpautop altogether, but it still doesn’t solve your problem. It actually creates a bigger one for the people using the Visual Text Editor built into wordpress and not the HTML Editor. By disabling wpautop, it removes ALL the paragraph breaks from all of your posts, which would require you to go back through and manually add them; just to remove that little paragraph break at the beginning.

Good news for you; there’s an easier way to remove that break, without disabling wpautop.

This tutorial will require you have some sort of knowledge of WordPress/PHP, and should not be done if you contain no knowledge of the language and/or the script.

First thing you’ll want to do is login to FTP, and find your wordpress directory (which only you will know where this is). For our sake, mine is /log.

1. Open up your directory /log
2. Navigate to /wp-includes
3. Find: formatting.php
4. Save it to your computer and open it up in a text editor (Wordpad, EditPad, Dreamweaver)

Find this piece of code:

$pee .= '

‘ . trim($tinkle, “n”) . ”

n”;

Which is on line 194. What that code does, is tell wordpress to add a paragraph break BEFORE and AFTER the content or post.

Now simply remove the

 

And you should now have this coding left:

$pee .= '' . trim($tinkle, "n") . "

n”;

Re-save your formatting.php file, and upload it back to the /wp-includes. Now once you have completed that, you’ll be able to go to your website and it will have removed that space.

REMEMBER: Once you have edited the formatting.php file, it will remove the space for ALL of your themes.

If you do not see that it has removed it, don’t worry, it’s more than likely that the CSS in your current theme has some sort of padding or margin to separate. It’s completely normal. Hope you enjoyed this tutorial, and you find some use for it. =]

PLEASE NOTE: Any time that you update wordpress you will need to edit the formatting.php file again, as wordpress will overwrite it with a newer version of it.