Automatically Close Comments in WordPress After Few Days

You type a controversial post, you get a flurry of comments and they keep coming as your post is digged, slashdotted … and then after a few days the post is forgotten in the archives to be picked up a year later by an occasional Googler, who decides to leave a comment, that features now in your recent comments in the sidebar and restarts the comment boom on an outdated, not-to-be-discussed now post. Remember many people look at the post date of an actively discussed article after the comment is posted and live and they have no way to change it.

A simple way to do it is to simply turn off comments in an individual post. But doing it to hundreds of posts after a period of time is difficult, especially if you are a popular quick posting blogger.

I found this Auto Shutoff Comments wordpress plugin on the official wordpress codex. It is a raw text code which you paste in any text editor like notepad in Windows and save as autoshutoff.php, then simply upload to your WordPress plugin folders and activate it. It will autoclose comments after 21 days. I think you can change the number of days it closes by tweaking the 21 value.

// Set $age to the age at which a post should become stale
$age = '21 DAY';

I have no need to use it now, but if you are looking for a simple solution to close off comments after a few days automatically, give it a try.

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.