Page Title: How to Use a Query to Bulk Delete WordPress Comments – Josh Stauffer

  • This webpage makes use of the TITLE meta tag - this is good for search engine optimization.

Page Description:

  • This webpage DOES NOT make use of the DESCRIPTION meta tag - this is NOT GOOD for search engine optimization.

Page Keywords:

  • This webpage DOES NOT make use of the KEYWORDS meta tag - whilst search engines nowadays do not put too much emphasis on this meta tag including them in your website does no harm.

Page Text: February 27, 2021 How to Use a Query to Bulk Delete WordPress Comments My WordPress database backups tend to get rather large over time. The reason for this is because of the sheer number of spam comments my blog receives. At the time of writing this I have 3,764 comments marked as spam. All of which I received over the past few weeks. You might be thinking… Aren’t there plugins that can help prevent spam comments? Well, sure there are. And aren’t there plugins that will delete spam comments in WordPress for you? Yep, there are those too. However, the point of this blog post is to show how we can delete these comments with some fairly simple queries. I’m assuming you already know how to use phpMyAdmin or a MySQL Client to run queries on your database. By the way, it’s a good idea to make a database backup beforehand in case things don’t go as expected. Alright, enough talking. Let’s see the queries. SELECT Queries Before we run the DELETE queries, let’s run these SELECT queries to get a preview of the records that will be deleted. wp_commentmeta table SELECT cm.* FROM wp_commentmeta cm INNER JOIN wp_comments c ON cm.comment_id = c.comment_ID WHERE c.comment_approved = 'spam' wp_comments table SELECT c.* FROM wp_comments c WHERE c.comment_approved = 'spam' It’s important to note that we are working with two different tables here. The wp_commentmeta table stores optional information about each comment. The wp_comments table stores the actual comment itself. DELETE Queries After previewing the records we want to remove, you are ready to run these DELETE queries. The order here matters. Run the DELETE query on the wp_commentmeta first. This is so we can prevent orphaned records. wp_commentmeta table DELETE cm FROM wp_commentmeta cm INNER JOIN wp_comments c ON cm.comment_id = c.comment_ID WHERE c.comment_approved = 'spam' wp_comments table DELETE c FROM wp_comments c WHERE c.comment_approved = 'spam' Your tables may have a different prefix. Just change ‘wp_’ to whatever your prefix may be. Comment Types If you want to target different comment types you can do so by looking for different comment_approved values. comment_approved = '0' /* pending comments */ comment_approved = '1' /* approved comments */ comment_approved = 'spam' /* spam comments */ comment_approved = 'trash' /* trashed comments */ Hope this helps. That’s all for now.

  • This webpage has 364 words which is between the recommended minimum of 250 words and the recommended maximum of 2500 words - GOOD WORK.

Header tags:

  • It appears that you are using header tags - this is a GOOD thing!

Spelling errors:

  • This webpage has 2 words which may be misspelt.

Possibly mis-spelt word: MySQL

Suggestion: My SQL
Suggestion: My-SQL
Suggestion: Myself

Possibly mis-spelt word: WordPress

Suggestion: Word Press
Suggestion: Word-press
Suggestion: Wordless

Broken links:

  • This webpage has 15 broken links.

Broken image links:

  • This webpage has no broken image links that we can detect - GOOD WORK.

CSS over tables for layout?:

  • It appears that this page uses DIVs for layout this is a GOOD thing!

Last modified date:

  • We were unable to detect what date this page was last modified

Images that are being re-sized:

  • This webpage has no images that are being re-sized by the browser - GOOD WORK.

Images that are being re-sized:

  • This webpage has no images that are missing their width and height - GOOD WORK.

Mobile friendly:

  • After testing this webpage it appears to be mobile friendly - this is a GOOD thing!

Links with no anchor text:

  • This webpage has no links that are missing anchor text - GOOD WORK.

W3C Validation:

Print friendly?:

  • It appears that the webpage does NOT use CSS stylesheets to provide print functionality - this is a BAD thing.

GZIP Compression enabled?:

  • It appears that the serrver does NOT have GZIP Compression enabled - this is a NOT a good thing!