Tutorial: How to globally disable WordPress Comments on all Posts & how to re-enable

0

WordPress allows to enable and disable your visitors’ comments via Settings > Discussions in the WordPress Backend.

These settings only apply to new Posts though and if you made specific settings for some posts these specific settings override the general settings in Settings > Discussions.

So rather sooner than later you may find yourself in the situation that you want to globally disable comments for all posts (no only future posts), e.g. when you discover lots of spam, want to switch to an external comment system like DISQUS or simply disable comments at all.

In that situation the WordPress Backend does not help at all.

You will have to make these adjustments yourself and luckily the relevant information is stored in the MySQL database that powers if you do not want to allow comments to be placed on your blog.

So we can adjust the settings for globally disabling and re-enabling comments on all WordPress posts with the corresponding MySQL commands.

To do so, please make sure you are running the latest version of WordPress and you have a recent backup of your MySQL database available just in case things go wrong!

The Process is straight forward:

  1. First you need to log into your phpMyAdmin panel
  2. Identifiy and select the WordPress database on the left from the database drop down list that is corresponding to your WordPress installation. If you have multiple databases, make sure you identify the right one by looking in your wp-config.php file in your WordPress Installation.
  3. Select the SQL tab on the top navigation
  4. You will see a Run SQL Query box where you need to enter the applicable MySQL Commands.

MySQL Query for globally disabling comments on all WordPress posts

UPDATE wp_posts SET comment_status = ‘closed’;

If you changed the standard “wp_” prefix during the installation of WordPress, please make these changes accordingly in the “wp_posts” query above, e.g. if your prefix is “xyz_” instead of “wp_” then you need to adjust the “wp_posts” above to “xyz_posts” to successfully disable all WordPress comments.

MySQL Query for globally (re-)enabling comments on all WordPress posts

UPDATE wp_posts SET comment_status = ‘open’;

Of course the same logic as in the disabling WordPress comments query above applies here as well: If you changed the standard “wp_” prefix during the installation of WordPress, please make these changes accordingly in the “wp_posts” query above, e.g. if your prefix is “xyz_” instead of “wp_” then you need to adjust the “wp_posts” above to “xyz_posts” to successfully re-enable all WordPress comments.

That’s it! How did it work for you?

Sharing is caring...
Tweet about this on TwitterShare on Google+Pin on PinterestShare on FacebookShare on TumblrDigg thisShare on LinkedInShare on RedditBuffer this pageFlattr the authorShare on StumbleUponPrint this pageEmail this to someone