Comments help the readers to communicate with the site owner and hence help in building an interactive blog. We have already discussed how to disable comments in our blog for new as well as existing posts and pages. In this post, we can see how to bulk delete all comments from our WordPress blog. Let us first understand about a few scenarios where we actually need to get rid of all comments from our site.
Why do we need to bulk delete comments?
We might be working on creating a new blog and need to do testing by inserting bulk posts and comments to our WordPress site. During this process, we may need to delete all the dummy comments. Also if we are planning to disable the comment feature of our blog we may need to delete all previously approved comments from our system. Whatever be the case, WordPress provides us with some easy methods to achieve this. Let us now see two different options to bulk delete all comments from our WordPress blog.
Option1: Bulk delete comments via the plugin
Install and activate Delete All Comments Of WordPress plugin.
Refer to this guide on plugin installation if you have any doubts. After activating the plugin let us go to Tools > Delete Comments section.
The total number of comments on our blog will be displayed here.
Now check the radio button All Comments and click the Delete Now button. This process will delete all comments including approved, pending, spam and trash. A confirmation message will be displayed once the comments are successfully deleted.
This process is irreversible and we cannot restore the comments once it is deleted. So be double sure about this before proceeding with the above steps to delete comments from our blog.
Option2: Bulk delete comments via phpMyAdmin
This option is a bit advanced and requires basic knowledge about WordPress database structure and tools like phpMyAdmin.Therefore I strongly suggest that newbie users avoid this method for deleting comments from the blog.
First, log in to the Cpanel provided by our hosting provider. Click on the phpMyAdmin option under the Databases section.
Within the phpMyAdmin, we have to identify the database for our required site. Click on the database name to view all the tables in this database.
The tables associated with the comments section in our blog are wp_comments and wp_commentmeta. Suppose if our tables are using a prefix like ‘mydb’ then the table name would be wp_mydb_comments and wp_mydb_commentmeta.
Now we have two available options to delete the contents of these tables.
a) Executing query via SQL window
Click on the SQL tab and paste the below two queries. Now run the queries by clicking the Go button. These queries will clear all the data from these two tables.
Note: If our objective is to get rid of certain specific comments the following queries can be executed.
- Delete all pending comments
DELETE from wp_comments WHERE comment_approved = '0'
- Delete all approved comments
DELETE from wp_comments WHERE comment_approved = '1'
- Delete all trash comments
DELETE from wp_comments WHERE comment_approved ='trash'
- Delete all spam comments
DELETE from wp_comments WHERE comment_approved ='spam'
b) Via Empty Option
After selecting the above two tables by checking the checkbox, locate the ‘With selected’ drop-down menu below the table list. Now select ‘Empty’ option from the drop-down menu.
phpMyAdmin will now display warning asking if we really want to clear data from these two tables.
Click on the Yes button to continue.
This process will delete all data from our comments section. This process is irreversible and the deleted comments cannot be restored later.