How do I remove spam comments from WordPress?

This guide shows how you can clean up spam comments in your database in phpMyAdmin.

Note: If you want to prevent spam comments by bots on your website's comment form, we highly recommend adding captcha protection like Google reCAPTCHA.

Step 1 - Click PHP and database settings in the one.com Control Panel

  1. Log in to the one.com Control Panel.
  2. Click PHP and database settings on the Advanced settings tile

CP-AdvancedSettings-PHPdatabase-settings.png


Step 2 - Open your database in phpMyAdmin

Click the phpMyAdmin drop-down menu at the top right corner, and select the database from which you want to remove spam comments.

CP-Select-database.png


Step 3 - Click the comments table

In the menu to the left, click on the comments table. It has the prefix followed by _comments like wp_comments, blog_comments, etc. This is where all your WordPress comments are stored.

open-comments-table-phpmyadmin-03.png


Step 4 - Delete spam comments

The easiest way to delete spam comments is to empty the entire table. This means that all comments will be deleted, also the legitimate ones. Alternatively, you can run queries to remove spam and unapproved comments in batches. We will show both methods, you should pick one.

Method 1: Empty the entire table

  1. Make sure you have opened the table that you want to empty.
  2. Click Operations in the menu at the top of the screen.
  3. Scroll down to the bottom and click Empty the table (TRUNCATE).
  4. Click OK in the pop-up window to confirm your action.

remove-spam-empty-table-04.png

Method 2: Run a query to remove spam and unapproved comments

  1. Click SQL in the menu at the top of the screen.
  2. Paste the following query to remove all comments marked as spam, replacing wp_comments with the name of your comments table.
DELETE FROM wp_comments WHERE comment_approved = 'spam';
  1. Click Go to confirm your action.
  2. Repeat the same steps for the following query to remove all unapproved comments - again replacing wp_comments with the name of your comments table. Unapproved comments have not yet been published on your site.
DELETE from wp_comments WHERE comment_approved = '0';

remove-spam-query-05.png


Related articles:

Was this article helpful?

Can’t find what you are looking for?

Start a chat

It's the quickest way to get in touch, every day of the year.

Give us a call

Available on weekdays from 10am to 2pm (UTC).