How to Change Akismet’s Delete Spam Schedule in WordPress

After we published our article on how to change WordPress trash schedule, one of our readers asked if it was possible to change the delete schedule for spam comments in Akismet. By default, Akismet keeps spam comments in your WordPress database for 15 days before… Read More »

The post How to Change Akismet’s Delete Spam Schedule in WordPress appeared first on WPBeginner.

After we published our article on how to change WordPress trash schedule, one of our readers asked if it was possible to change the delete schedule for spam comments in Akismet. By default, Akismet keeps spam comments in your WordPress database for 15 days before deleting them. In this article, we will show you how to change Akismet’s delete spam schedule in WordPress.

How to Change Akismet's Spam Delete Schedule in WordPress

Why Change How Akismet Deletes Spam in WordPress?

This tutorial is for Akismet plugin only. If you are not using it, then check our guide on why you should start using Akismet.

Akismet allows you to combat comment spam in WordPress. It monitors all comments, pingbacks and trackbacks.

Spam comments reside in your database, which means they increase your database backup size. Deleting them sooner may help keep your database size a bit smaller.

While some users may believe that deleting spam comments improves database performance, we don’t think it has a major effect on database performance in most circumstances.

If you are receiving thousands of spam comments, and you try to delete them manually, then it could affect your site’s performance. See our guide on how to batch delete spam comments in WordPress.

On the other hand, some users may want to keep spam comments for a longer period, so that they can review them later to avoid false positives.

Having said that, let’s see how you can change the delete schedule for spam comment in WordPress with Akismet.

Changing Spam Comment Delete Schedule in WordPress with Akismet

Akismet automatically deletes spam comments after keeping them for 15 days in your database. This gives you time to manually review spam comments.

If it marked a genuine comment as spam, then you can mark it as not spam. This is how Akismet learns and improves it’s algorithms to catch spam comments more efficiently.

Comment spam folder

You can change the number of days Akismet should keep spam comments in your database. Simply add this code to your theme’s functions.php file or in a site-specific plugin.

add_filter( 'akismet_delete_comment_interval', 'custom_spam_delete_interval' );

function custom_spam_delete_interval() {
	return 7;
}

Change 7 with the number of days you want to keep a comment. This filter simply modifies Akismet’s spam deletion schedule.

Changing the number to 0, will allow Akismet to delete all comments on its next comment delete schedule. This will not give you much time to review spam comments.

You can see your changes in action by visiting Settings » Akismet page. Scroll down to the bottom of the page, and you will see a note in tiny letters saying ‘Spam in the spam folder older than 7 days is deleted automatically.’

Comment spam delete schedule shown in Akismet settings

It will replace 7 days with the number of days you used in your filter.

Note: When spam comments are deleted, they are not sent to trash, so you cannot retrieve them back.

We hope this article helped you change Akismet spam comment delete schedule in WordPress. You may also want to see our guide on how to how to block spam comment bots in WordPress with honeypot.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Change Akismet’s Delete Spam Schedule in WordPress appeared first on WPBeginner.