Disable WordPress comments (how-to)


The WordPress comment system can be a bless for your blog, because of the user interaction. However, when the WordPress comment option is abused by spammers, it becomes a real pain in the “@ss”. With thousands spam reactions, disabling -and removing- WordPress comments is the only way to go. Here is how to disable WordPress comments in both the WordPress Dashboard interface and in your MySQL database.

In the WordPress Dashboard, WordPress has a nifty Discussion Settings in which you can enable – or disable – comments. The disadvantage of this discussion setting is: it only applies to new articles, not old articles.

Disable WordPress comments through Discussion Settings

Assuming WordPress comments are enabled: to disable WordPress comments through the Discussion Settings of the WordPress Dashboard, log on to your Dashboard and browse to Settings > Discussion. Here you’ll find a check box Allow people to post comments on new articles. Uncheck that check box.

Now, comments are disabled for new articles and posts. This can be overridden when creating a new post.

enable or disable WordPress comments
WordPress discussion settings

But what if you have a hundred or more posts? Do you have to edit all of them to disable commenting? No! Fortunately, you can use the power of MySQL to disable and close comments for existing posts.

Disable WordPress comments on all posts through MySQL/phpMyAdmin

As said, you cannot close comments on existing posts through the WordPress Dashboard. Unless you want to edit all your posts… Therefore, we’ll use the power of MySQL to disable WordPress comments on all posts, in one go. Just to make life a bit easier.

To disable, or close, the comments on existing posts, you’ll need your MySQL database credentials. And a way to log on to your database, for example with phpMyAdmin or a mysql command-line interface. Turn to your hosting provider for more information and details. Once logged on to your MySQL database, through phpMyAdmin, click the WordPress wp_posts table on the left. We’re looking for the column called comment_status. The comment_status column will probably have the value “open” for posts, and we need to set that to “closed”. Here’s how:

Click the SQL tab in phpMyAdmin, and copy/paste the next MySQL statement in it:

UPDATE `wp_posts`
  SET `comment_status` = "closed"
  WHERE `comment_status` = "open";Code language: JavaScript (javascript)

Don’t forget to change the wp_ table prefix to reflect your database situation.

WordPress comments enabled on individual posts

Now the WordPress comments are closed (disabled) for all your posts, spammers can no longer abuse your blog to spread their junk. If you want to enable comments on individual and/or new posts, there is a little Discussion setting in the Add New Post and Edit Post sections. Check the option check boxes you want to enable.

Enable WordPress comments for individual posts
Enable WordPress comments for individual posts

Re-enable WordPress comments globally

If you have disabled the WordPress comments globally for all posts, you can use the following MySQL query to re-enable the comments for all published posts:

UPDATE `wp_posts`
  SET `comment_status` = "open"
  WHERE `comment_status` = "closed"
  AND `post_status` = "publish";Code language: JavaScript (javascript)

Captcha protection for WordPress comments, or block comment spammers

Another option is to secure WordPress comments with a captcha. Just follow my post Secure WordPress with a Captcha for a how-to. Of course, once can also manually block WordPress comment spammers.

foto van Jan Reilink

About the author

Hi, my name is Jan. I am not a hacker, coder, developer or guru. I am merely a systems administrator, doing my daily SysOps/DevOps thing at cldin. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, websites & optimization.

0 0 votes
Article Rating
Notify of
1 Comment
Oldest Most Voted
Inline Feedbacks
View all comments
6 years ago

great tutorial. I used for my site this method and this really work

Would love your thoughts, please comment.x