For WordPress Blogs And Websites
Today I wanted to disable all the comments in a wordpress website to make it look MORE like a website, not like an interactive blog. If I only had a few posts it’s easy to do it in the regular dashboard one at a time. But as this particular site had more than 100 posts, I needed an option that handled the job right across the board.
Since this information is stored in the database, it’s actually quites easy to edit the open or close comments option by using an SQL database query.
PLEASE NOTE: Before you go on, there is now an even easier way to disable comments in wordpress site-wide with a terrific plugin. You can disable on posts/pages or media or all of them. But here are the instructions for doing it in phpmyadmin just in case.
Note: I’m assuming you are using the latest versions of wordpress and have access to phpMyAdmin and you’ve taken a backup of your database as a precaution.
Here’s what to do:
1. Log into your phpMyAdmin control applet
2. Locate and select your applicable WordPress database on the left from the database dropdown list
3. Select the SQL tab from the navigation tabs at the top
4. TO OPEN ALL COMMENTS Within the Run SQL Query box add the following code and click go:
UPDATE wp_posts SET comment_status = ‘open’;
5. TO CLOSE ALL COMMENTS Within the Run SQL Query box add the following code and click go:
UPDATE wp_posts SET comment_status = ‘closed’;
If an error occurs that says something like #1146 – Table ‘***_yourdatabasename.posts’ doesn’t exist, check that the wp_post prefix from the database list is correct (I’ve deliberately changed my database prefixes for added security, if you’re not sure you’ll see it recorded in the left hand side column and can easily change the code to match accordingly). You might change the first part of the code to something like this.
6. TO OPEN ONLY THE COMMENTS THAT WERE CLOSED Within the Run SQL Query box add the following code and click go:
UPDATE wp_posts p SET comment_status = ‘closed’, ping_status = ‘closed’ WHERE comment_status = ‘open’;
7. TO CLOSE ONLY THE COMMENTS THAT WERE OPEN Within the Run SQL Query box add the following code and click go:
UPDATE wp_posts p SET comment_status = ‘open’, ping_status = ‘open’ WHERE comment_status = ‘closed’;
PLEASE NOTE: This will effect both posts and pages, so just check after it’s done. I generally prefer to have post comments open and page comments closed.
If you see a success notification, you will have enabled or disabled the ability to comment on your posts across your entire site. Well Done!