How To Enable Or Disable Comments Quickly

Here is a little tip you can use to turn comments on/off at once site wide. Why do this? While it's true you can toggle comments on and off by navigating to Settings > Discussion this does not affect previous comments. In other words it is not retroactive and only affects comments from that point forward. Let's assume you have created a development blog on a test site. Then you import some dummy content via either XML or SQL. Being a dev site perhaps you don't want comments. Toggling the comments off from the Dashboard will only affect any future posts you make but will have no bearing on the posts currently residing on the test site. This is how you can solve the problem.

Access your database via phpMyAdmin and run the following query ...

UPDATE wp_posts p SET comment_status = 'closed', ping_status = 'closed' WHERE comment_status = 'open';

If you want to batch enable comments run the query below ...

UPDATE wp_posts p SET comment_status = 'open', ping_status = 'open' WHERE comment_status = 'closed';

It goes without saying you should always make a backup prior to working with your database. Actually you should be making regular backups anyway.

About the author
Len has been blogging for over 10 years and is a rabid WordPress fan. In addition to blogging here you can find him writing the occasional article and toiling away in the forums at WeblogToolsCollection.com. He also hangs out at the WordPress support forums lending a hand where he can. You can find his political scribblings at RiteTurnOnly.com

Leave a Reply

CommentLuv Enabled