How To Hide Deleted Comments In Blogger

It’s really annoying when someone spams your comments in Blogger (or accidentally posts twice). You can delete the comment, but it’s not “really” deleted… instead it has a message saying the comment was deleted by an administrator. In the case of a spammer, it’s really ugly to have 20 or so of those if you ask me.

So I decided to come up with a hack that will remove it. This only works if you run your blog on your own server (FTP or SFTP published) and your server is running Apache with PHP extensions installed.

First I created a PHP file and dropped it in my blogger base directory:

myfile.php file:

<?php

    $file
= file_get_contents ($_REQUEST['file']);

    
$a = substr_count ($file, 'deleted-comment');

    
$b = preg_match ('/<h4>(.*?) Comments:<\/h4>/i', $file, $matches);

    

    echo
str_replace ('<h4>' . $matches[1] . ' Comments:</h4>', '<h4>' . ($matches[1] - $a) . ' Comments:</h4>', $file);

?>

Then I created a .htaccess file in that same folder:

.htaccess

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} 20..\/..\/

RewriteRule ^(.*) myfile.php?file=$1

Great… problem solved. Basically it reads the file and spins it through the script before it’s output to the user.

BTW, this is not a detailed “how to”, so use at your own risk and don’t email me if it doesn’t work. 🙂

4 thoughts on “How To Hide Deleted Comments In Blogger”

  1. Excellent thankyou

    I wanted to edit some stuff on my pages but didnt know how to go about it since blogger inserts the html.

    With this in mind I’m planning something which may take me a while to complete – but it’ll be worth it.

    This gives me a base to get started

  2. Hello, I am from Greece and I would like to ask you something about comments in blogspot. Is there any way to hide only the old comments and show only the comments in the most recent post?

    Also, is there any way to delete all the comments at the same time and not one by one?

    Thanks in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *