WordPress comment spam is becoming an issue for every webmaster. If you do not have any spam protection setup on your WordPress blog, one day you might find yourself with thousands of spam/pending comments laying inside your website. This tutorial will explain how to easily delete all unnecessary comments from WordPress website.
What you’ll need
Before you begin this guide you’ll need the following:
- Access to WordPress Admin area
- Access to phpMyAdmin
Table of Contents
Option 1 — Deleting WordPress comments using phpMyAdmin
Login to your hosting control panel and access phpMyAdmin. Inside phpMyadmin, select your WordPress database (see this tutorial to find out your WordPress database name) and click on SQL tab in order to run a query.
IMPORTANT: To prevent unwanted data loss, it’s strongly recommended to create backup of your MySQL database before running any queries.
Depending on what you want to achieve run the following queries:
Remove all pending comments in WordPress:
DELETE from wp_comments WHERE comment_approved = '0'
Remove all spam comments in WordPress:
DELETE from wp_comments WHERE comment_approved = 'spam'
Remove all approved comments in WordPress:
DELETE from wp_comments WHERE comment_approved = '1'
Remove all trash comments in WordPress:
DELETE from wp_comments WHERE comment_approved = 'trash'
Note that depending on your WordPress setup, the prefix of comments table (wp_ in this case) can be different.
Simply copy and paste the query you want to run into the SQL tab and press Go button.
Option 2 — Deleting spam comments via WordPress Admin Dashboard
Login to your WordPress Admin Dashboard and navigate to Comments -> Spam section. You will be able to see Empty Spam button and by clicking it you will delete all comments on your WordPress flagged as SPAM.
Option 3 — Deleting pending comments using WordPress plugin
One of the easiest ways to delete all Pending comments is by installing WordPress plugin called Delete Pending Comments.
You can easily install this plugin by navigating to your WordPress Admin Dashboard and clicking on Plugins section. Inside Add plugins section, search for Delete Pending Comments plugin and install it. For more detailed tutorial how to install WordPress plugins click here.
Once installation of the plugin is complete access Comments -> Delete Pending Comments section. Copy and paste security phrase into the text field and press Delete Pending Comments button.
Congratulations, you have learned how to remove all unwanted comments in your WordPress blog. This can be very helpful while dealing with automated spam comments on your website.