Since closing WordPress comments on older posts the amount of spam I am getting is under 10 per day.
If you would like to ask a question about an older post, please use my contact form.
You can close comments after X number of days under Settings > Discussion > Other Comment Settings > Automatically Close Comments on Articles Older Than X Number of Days.
Closing WordPress Comments
Since I neglected my blog for so long, there aren’t many legitimate comments coming in right now so there is no reason to leave the old posts open for spammers to target.
You can also add the following function found via Jimmy’s Code to your theme’s functions file. This will display a message saying that comments will close after the number of days set in the discussion settings and a message for when comments are already closed. This function is specific to the Genesis Framework. If you are using a different theme you would change genesis_after_comment_form to comment_form_after in the add_action part.
add_action('genesis_after_comment_form', 'showcommentsopen'); function showcommentsopen() { $numdays = get_option('close_comments_days_old'); if (is_single()) { // we are on a blog post... if (comments_open()) { // ...and comments are open... if ($numdays !== 0) { // ...but they are set to close after N days... echo 'The comment form will be available for ' . $numdays . ' days from the date the article was published.
'; } } else { // comments closed echo 'Comments are closed. Please <a href="https://www.kimwoodbridge.com/contact/">contact me</a> for specific questions ' . ' or subscribe to my newsletter.
'; } // end open check } // end single check }
Comments Open
Comments Closed
Do you still have comments open on your site? Do you close comments after a certain amount of time? Do you think a custom message for closed comments like in the function is useful?
Photo credit: 93482748@N02
Raphael says
Hello Kim,
Thannks alot for sharing this article. I don’t get as much spam messages as that, i use Akismet also and i get an average of about 20 spam comments weekly. Closing comments after 100 days is really a good idea to me, and i’ll implement that on my blog.
I’m not really good with HTML codes, and i’m not running on a genesis framework, i’m confused about what part of the theme editor i should paste the code.
Thanks for sharing this Kim.
Kim Woodbridge says
Hi – The code goes in your theme’s functions file. If you aren’t familiar with editing code, I wouldn’t edit that file as it could mess up your site. The code will work with non-Genesis themes but the part of the code mentioned in the article would need to be changed. This is just to add a message about closed comments – you can still close them after X number of days without adding the message. Since I started closing comments, my spam problem has almost disappeared!
Robin khokhar says
I was looking some good coding to disabled comments and your code has worked well for me. As i was not wanted to use any plugin for disabling comments.
so thanks a lot.
Kim Woodbridge says
Great! I’m so glad it worked for you.