Tagged: wordpress discussion management

In a bid to combat the comment spamming issue, WordPress developers often choose to use plug-ins. If you want to block spam comments on your WP blog permanently and make way for genuine discussions, you need to know how to bring SQL to play. Here are some handy SQL codes that can help you manage WordPress more efficiently than you can even imagine. You can use PHPMyAdmin, a free-to-use and open-source tool, which can make spam removal and comment management a cakewalk for you. Just do not forget to take a backup of the database before you run SQL+ queries on your server.

How to remove all comments from the server database

Use the below-furnished query to remove all comments marked as ‘spam’ from your database.

DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam';

The best part is, the code works perfectly on all WP versions including the most recent, WP 3.9.2!

How to disable/enable comments

In the WP database, under the ‘wp_posts’ table, you can find a column named ‘comment_status’. The column will contain the following values for each post or row.

Open (comments are open to every visitor)

Closed (comments are closed to every visitor)

Registered_only (Comments can only be seen by registered and logged-in users)

You may run the following SQL queries (using phpMyAdmin or any other open source tool which is used in MySQL) to change the default comment-management settingas. (again, do not forget to take backup of your database)

SQL, if used properly, can be highly instrumental in WordPress Comment Management. Try SQL language for yourself and you would know why WordPress developers have so much love for this database language.