SQL commands can be used for WordPress from phpMyAdmin to delete, approve the comments and pingbacks in one click.
Previously, we wrote Indispensable MySQL queries for custom fields in WordPress, this time few examples of SQL commands.
What is our goal to use these SQL commands?
We can these SQL commands from phpMyAdmin for WordPress to delete all the spam comments, open and close all comments, Enable / disable comments, pingbacks and trackbacks etc just using these SQL commands.
---
Expected User Level for using these SQL commands: Advanced.
Understanding how these SQL commands will work
You have to access phpMyAdmin as Admin with all privileges. Those who are beginners and wants to experiment, it is advisable to test it first on an offline installation.
SQL commands
1 | DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam' ; DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam'; |
Deleting this will delete all spam comments at once:
To close comments on ALL published post:
1 | UPDATE wp_posts SET comment_status = 'closed' ; UPDATE wp_posts SET comment_status = 'closed'; |
Enable / disable comments, pingbacks and trackbacks:
1 | UPDATE wp_posts SET comment_status = 'open' , ping_status = 'open' WHERE comment_status = 'closed' AND post_status = 'publish' ; UPDATE wp_posts SET comment_status = 'open', ping_status = 'open' WHERE comment_status = 'closed' AND post_status = 'publish'; |
Conclusion on SQL commands
The above SQL commands are only few examples. You will find more similar SQL commands in SQL specific sites.
If you want learn more, you can buy some nice books on SQL commands. Running WordPress is not difficult, but playing with advanced settings increases knowledge of those who are interested.