First of all. Happy new year everyone! This is my first post for the year 2014, and I would like to share a useful MySQL snippet wherein you can delete a series of comments based from an author’s IP. We all know for a fact that akismet can’t block all spam comments. My blog itself has a lot of spam comments lately, and I’ve been having a hard time delete it one by one.
Because of this daunting task, I just deleted it inside my phpmyadmin. I delete all comments from a spam commenters based on their IP range. If you don’t want to delete all comments, just the comments from this IP up to this UP, then this MySQL command will help you do that job fast.
[code lang=”sql”]
DELETE FROM wp_comments WHERE comment_author_IP BETWEEN ‘192.X.X.X’ AND ‘192.X.X.X’
[/code]
Just replace the IP address with the IP address range that you want to delete. If you want to delete all comments from a single IP, then you can use this command.
[code lang=”sql”]
DELETE FROM wp_comments WHERE comment_author_IP =’192.X.X.X’
[/code]
That’s it! If you have a lot of pending comments that you want to delete, because you’re pretty sure that it’s all spam, here’s a snippet that will help you.
[code lang=”sql”]
DELETE FROM wp_comments WHERE comment_approved = 0
[/code]
That’s all for today! Happy WordPress blogging! Let’s start the year right be deleting all spam comments in your WordPress blog!
Leave a Reply