Family Encyclopedia >> Electronics

How to change Akismet spam removal schedule in WordPress

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

How to change Akismet spam removal schedule in WordPress

Why change how Akismet removes spam in WordPress?

This tutorial is for the Akismet plugin only. If you're not using it, check out our guide on why you should start using Akismet.

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

Spam comments reside in your database, which means they increase the size of your database backup. Removing them sooner can help keep your database size a bit smaller.

While some users believe that removing spam comments improves database performance, we don't believe it will have a significant effect on database performance under most circumstances.

If you receive thousands of spam comments and try to delete them manually, it could affect the performance of your site. 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.

With that being said, let's see how you can change the spam comment removal program in WordPress with Akismet.

Changing WordPress Comment Spam Deletion Schedule with Akismet

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

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

How to change Akismet spam removal schedule in WordPress

You can change the number of days that Akismet should keep spam comments in its 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 to the number of days you want to keep a comment. This filter simply modifies Akismet's spam removal schedule.

Changing the number to 0 will allow Akismet to remove all comments on its next comment removal schedule. This won't give you much time to review spam comments.

You can see your changes in action by visiting Settings »Akismet page. Scroll to the bottom of the page and you'll see a note in lowercase that says:'Spam in the spam folder older than 7 days is automatically deleted.'

How to change Akismet spam removal schedule in WordPress

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 the trash, so you cannot recover them.

We hope this article helped you change the Akismet spam comment removal schedule in WordPress. You can also check out our guide on how to block comment spam bots in WordPress with honeypot.

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