12Feb2010

WordPress Tip – Disable comments on ALL posts

Wordpress Logo

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';

Author
Dan Harrison

About the Author

Dan has been creating websites since 2003, and is 100% self-taught. Through lots of trial and error, Dan has learnt how to create successful websites, sharing his knowledge on RunningAWebsite.com. Dan is also a highly experienced UK-based Wordpress Developer, offering a range of specliased Wordpress Developer Services through his agency WP Doctors.

Dan Harrison has written 37 articles on Running A Website.

Sharing is caring.
  • Subscribe to our feed
  • Share this post on Delicious
  • StumbleUpon this post
  • Share this post on Digg
  • Tweet about this post
  • Share this post on Mixx
  • Share this post on Technorati
  • Share this post on Facebook
  • Share this post on NewsVine
  • Share this post on Reddit
  • Share this post on Google
  • Share this post on LinkedIn

Discussion

8 responses to "WordPress Tip – Disable comments on ALL posts"

  • Julian says:

    Thanks Dan, a very valuable tip!! Could have used this in the past but I’m sure I will require it again soon. :)

  • The_Landlord says:

    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.

  • Dan Harrison says:

    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

  • Steve M says:

    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.

  • Rob Barham says:

    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.

  • Steve says:

    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!

  • Dan Harrison says:

    Glad it was useful Steve! :)

    Dan

Leave a Comment