define('DISABLE_WP_CRON', 'true'); wpautop - HTNet

You are currently browsing the archives for posts tagged as wpautop.

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?