Delete all one-word WordPress comments at once

by on Feb.03, 2013, under Wordpress

A few of my blogs I’m maintaining suffer from a load of senseless one-word comments. I tried to find a simple way to delete all wordpress comments containing only one word at once. This is what I did:

First log into phpmyadmin or login via command line to your mysql database. For safety reasons you should create a backup before you delete anything…

You should test before deleting your comments with this query. It displays all comments (and their ids) which have only one word:

SELECT comment_ID, comment_content 
FROM wp_comments 
WHERE REPLACE( TRIM( comment_content ) , ' ', '' ) = TRIM( comment_content ) ;

If the output is ok, you can delete them with this query:

DELETE 
FROM wp_comments 
WHERE REPLACE( TRIM( comment_content ) , ' ', '' ) = TRIM( comment_content ) ;

INFO: You can add AND comment_approved = ’0′ if you want to delete only the pending comments.

That’s it. Neat and simple solution how to erase all (mostly senseless) comments with one word in wordpress, isn’t it?

Share
:, , , , , ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!