SQL for Comments and Pings in WordPress
Just a snippet of SQL (Structured Query Language) that comes in handy for WordPress. If you have phpMyAdmin on your account you can just cut and paste these two queries into the SQL area and you’re away. What do they do? If you’re being hammered by spam you don’t want to have to revisit every article and shut off comments and pings - in the past I’ve found the WordPress administration area gave unreliable results at times when turning them on and off. This method offers fine grained control.
So the first query just closes all comments and pings on every article. The second opens comments and pings on twenty articles - change the number on the end to suit your needs. So to close them:
update wp_posts set comment_status='closed', ping_status='closed' where comment_status='open' or ping_status='open'
and to reopen them:
update wp_posts set comment_status='open', ping_status='open' where comment_status='closed' or ping_status='closed' order by wp_posts.ID desc limit 20;


