How to temporarily disable (turn off) all new comments on your WordPress blog

First published on May 21, 2007

There are currently two options in WordPress to disable comments. One is under “Options… Discussion” where you can toggle “Allow people to post comments on the article” on and off. But this only applies to future posts. The other option is to individually toggle the “Allow Comments” option for each post. But then if you want to temporarily disable ALL comments, this is time-consuming to implement and to undo (and if you use a script to change the setting in the database for all posts… that is a permanent solution for all posts).

If the above options don’t appeal to you, and your situation is that you want to temporarily disable new comments, but still display existing comments (handy if you’re going on vacation), do the following two things:

1) Turn off the display of the comment form in your Comments file in your template. To do this, go to “Presentation… Theme Editor…” then edit the Comments file. Find the part in the file that looks like this (it is probably slightly different, depending on what theme you’re using):

<?php if ('open' == $post->comment_status) : ?>
<h3 id="respond">Leave a Reply</h3>

Change it to this:

<?php // if ('open' == $post->comment_status) : ?>
		<p>Comments are temporarily disabled</p>
<?php if (1 == 2) : ?>
<h3 id="respond">Leave a Reply</h3>

Change it back when you’re ready to re-enable comments.

2) Either rename your wp-comments-post.php file (in the root of your WordPress directory) to something unguessable like betyoucantguessthis.php (then change it back when you’re ready to re-enable comments) OR install (and de-activate later)
this plugin that I whipped up
where you can temporarily disable all comments but choose to still allow trackbacks and / or pingbacks.

The second step is necessary because spammers don’t need to visit your comment form to be able to post comments.

If you’re already using my anti-spam plugin then the second step is already done by that plugin, since it only allows people to comment through the form on your blog (which was hidden in step 1).


5 Responses to “How to temporarily disable (turn off) all new comments on your WordPress blog”

  1. Tim says:

    Hey there… I’m googling my issue, and I found this.. this is exactly the reverse of what I want to do.

    I’ve a client that has 200 posts in his wordpress, and he didn’t want comments last year. Now he wants to allow comments. No problem for future comments.

    Wondering if you perhaps tripped over this one: how to recursively turn on comments on past posts?

    If you’ve got a trick up your sleeve I’d like to hear it if you got a minute :)

    Thanks for readin’


  2. Peter says:

    You can do this at the database level with the database query:

    UPDATE wp_posts SET comment_status = 'open'

    For trackbacks and pingbacks:

    UPDATE wp_posts SET ping_status = 'open'

  3. icelebpics says:

    i cant find the specific code in my comments.php
    comments r disabled in my blog and i want to enable it
    can u plz help me how to enable an email me

  4. Peter says:

    If you want to enable comments on a specific post, edit the post and check the “Allow Comments” checkbox on the right, in the Discussion window. If you want to allow comments for subsequent posts, look under the Discussion sub-menu under the Options menu. This setting should be checked: “Allow people to post comments on the article”.

    If you previously had comments disabled for all posts, the quickest way to enable comments is to run the MySQL database query above.

  5. B-sting says:

    This is a REALLY late reply, but I think in my case the second step isn’t necessary. I’m currently moving my blog from one server to another server at another host. I completely backed up everything and restored it in the new location. But now I found out changing the DNS-entry to point to the new server is going to take a little longer than I expected.

    So, I wanted to prevent people from commenting on the old blog, cause I was too lazy to do the whole export/import thing again. Step 1 in your entry effectively did that.

    Step 2 however isn’t relative in my case, I think, because spammers who know the exact location of the reply-script can leave comments all they like. First of all because my WordPress uses Aksimet to catch spam posts and secondly because when I move the servers, their new comments will be effectively trashed any how.

    Also thanks for this post, it was helpful! (Which creepily enough is what usually the spam-commenters say to my posts, but at least I mean it!)

Speak your mind

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word