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).