I love wpautop. It deals with post formatting very well 99% of the time. For me, the 1% time it’s not working properly is when it’s handling HTML comments.
In case you’re wondering why the hell do I need to put HTML comments in posts; well it’s for things such as embedding AdSense Deluxe content. It may also be useful for Section Targeting, but I don’t use it.
The problem is that wpautop wrap comments in a paragraph tag (<p>). Why it does that is beyond me. Anyway, my fix is to add the following lines in the wpautop function codes in formatting.php just before the line that says return $pee;;
$pee = str_replace("<p><!--", "<!--", $pee);
$pee = str_replace("--></p>", "-->", $pee);
formatting.php is inside the wp-includes directory of your WP installation in case you’re wondering
Anybody know why this isn’t already in wpautop?









April 18th, 2007 at 1:57 pm
wow… maybe my blog need this. sure deep one esp. for me
April 8th, 2008 at 3:46 am
xD
June 12th, 2009 at 12:04 am
Test
May 21st, 2010 at 4:56 pm
test
October 5th, 2010 at 8:55 pm
Thank you so much! I’ve been researching this issue for over an hour this morning and it’s been driving me crazy! I like to write really well-formatted code with comments and this was really screwing up my layouts. You saved me a ton of time trying to figure out how to write those two lines myself.