Delete WordPress Comments based on IP Range

delete-based-on-comment-ips
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.

DELETE FROM wp_comments WHERE comment_author_IP BETWEEN '192.X.X.X' AND '192.X.X.X'

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.

DELETE FROM wp_comments WHERE comment_author_IP ='192.X.X.X'

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.

DELETE FROM wp_comments WHERE comment_approved = 0

That’s all for today! Happy WordPress blogging! Let’s start the year right be deleting all spam comments in your WordPress blog!

Do you love this article and you want to receive more interesting posts from Bryan Veloso? Why not subscribe to this blog via e-mail? It's easy! Just enter your e-mail address below and confirm your subscription by clicking the activation link that will be sent to your e-mail! Get your free subscription now!

Enter your email address:

This entry was posted in Geekery, Internet and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *