Last updated on January 29th, 2022 at 11:04 am

While checking my website today I saw around 3792 comments pending for approval. It is for sure that my website is attacked by WordPress comment spam. They will post thousands of comments spamming the entire website and if your website is having less resource then it might affect the website performance as well.

If you are planning to delete these comments using the admin interface of WordPress it will take a lot of time and will be really difficult.The easiest method to delete these comments is directly logging in to your mysql database and issuing a delete command. In case if you don’t have access to your server use phpmyadmin instead and copy paste the query below.

First select your WordPress database using the below sql query OR If you have phpmyadmin click on the database which your WordPress is using.

use YOUR_DATABASENAME;

Issue the query below to count the number of comments pending for approval.

mysql> SELECT count(*) from wp_comments where comment_approved = '0';
+----------+
| count(*) |
+----------+
|     3792 |
+----------+
1 row in set (0.00 sec)

Compare the above count with the value in your PENDING section under WordPress Admin comment interface [http://YOUR_WEBSITE_NAME/wp-admin/edit-comments.php].

Once confirmed issue the delete command.

mysql> DELETE FROM wp_comments WHERE comment_approved = '0';
Query OK, 3792 rows affected (1.64 sec)

Confirm that all the pending comments got deleted.

mysql> SELECT count(*) from wp_comments where comment_approved = '0';
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

*Note:- Make sure that you don’t have any useful comments in between when you issue the bulk delete using MySQL.

Leave a Reply

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