define('DISABLE_WP_CRON', 'true'); Simple HTML Comments Fix For wpautop Function - HTNet

Simple HTML Comments Fix For wpautop Function

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?

5 responses to “Simple HTML Comments Fix For wpautop Function”.

  1. papajoneh Says:

    wow… maybe my blog need this. sure deep one esp. for me 😉

  2. egggegge Says:


  3. abc harald Says:


  4. test Says:


  5. Erika Says:

    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. 🙂