WordPress Tip – Disable comments on ALL posts

If you’re running a website with a number of pages, you might want to disable comments on all pages and posts at once. There’s no feature within WordPress to do this, however, you can achieve this result using a little bit of SQL.
For this tip, I’m assuming that you’re comfortable using phpMyAdmin with your web hosting package.
I’m not aware of a plugin that disables comments, but if you do hear of a plugin that’s able to do this, please let me know. I have no plans to add this to a plugin any time soon. In phpMyAdmin, execute the following SQL, which will disable comments and pingbacks on all currently published (and draft) pages and posts.
UPDATE wp_posts
SET comment_status = 'closed', ping_status = 'closed';






Thanks Dan, a very valuable tip!! Could have used this in the past but I’m sure I will require it again soon.
Might be worth noting that this solution only applies to existing posts. If a new post is published, it will by default allow comments, unless the query is executed again, or the user ticks the “disable comments” for that particular post before publishing it.
Alternatively, there is an option in settings > discussions, which may be useful. You could untick the “Allow people to post comments on new articles” option. So after running the query, just tick that box, and all future posts will also be disabled from comments.
Also there is a “Automatically close comments on articles older than [insert day count]” option. If you enter “0 days”, it MAY disable all posts from comments – i’ve never tried it. But almost certainly, if you:
1) untick the “allow people to post comments on new articles” option
2) enter “1 days” in the “Automatically close comments on articles older than”
That should, in theory, have the same affect as what you’re trying to acheive by running that query manually.
Cheers.
If you run the query that I specify, plus until option 1, that will prevent you from needing to worry about comments. Your method is great for avoiding any SQL.
Dan
Dan,
Thanks for this, it’s a really helpful little snippet had been searching for a while before I came across your post!
The Digitalpoint suggestion is a good one as well. You can get marketing tips there as well, and the first thing they’ll tell you is to get a domain name.
Hi Dan,
I normally hack the theme to take out the comments form but recent themes I have been using have an option in the theme options and on each post / page whether or not to have the comments box.
Dan – you are a genius! I had a blog with over 1,400 posts ALL with comments and pings enabled…and with your help I turned them all off in 0.0689 sec (Query execution time).
Thanks mate!
Glad it was useful Steve!
Dan