Disable WordPress Comments on All Posts

Wordpress LogoWordPress, in my opinion, is currently on of the best blogging and website back-ends available today.  It’s flexibility gives you the ability to configure you site in countless ways.  One of it’s features is it enables visitors the opportunity to leave comments on your individual posts.  Sometimes, the ability to leave comments on certain sites may not be appropriate or otherwise needed.

On the WordPress Dashboard administrators can disable commenting for the entire site.  This can be found under Settings, Discussions, and un-checking the appropriate boxes.  The issue with this procedure is it only removes commenting for future posts.   One option to remove comments on existing posts is you can go into the individual posts and un-checkAllow Comments” in the Discussion portion of the post.  This option is acceptable if you only have a few posts but what if you have thousands of posts that you want to remove the ability to leave comments on?

Since WordPress resides on a database, you can open your database and run a simple script to close comments on all posts.

    • Open your WordPress database using the tool of your choice.  I use SQLyog Enterprise.

Create a Query with the following string:

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

  • Your individual table names in your database may be different than the ones I use, therefor you may need to modify the query by changing the table name “wp_posts” to match the name of your table.
  • Run the Query and it will change the comments status on all of your posts from “Open” to “Closed“.  The opposite may also be preformed to open comments on all posts by swapping “closed” and “open
  • NOTE:  before performing any queries on your WordPress database, ALWAYS backup first!

This procedure has worked very well for me in the past.  I have used it to remove the ability to leave comments on a site with over 13,000 posts.  The entire procedure took less than 2 minutes vs going into all 13,000 posts individually!  One additional thing to keep in mind, this procedure closes comments on all posts, preventing the ability to leave new comments.  It does not remove existing comments.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

Subscribe without commenting