Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Change Akismet’s Delete Spam Schedule in WordPress

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

After we published our article on how to change the WordPress trash schedule, one of our readers asked if it was possible to change the deletion schedule for spam comments.

Akismet is a comment spam plugin that comes with WordPress but is not activated by default. Akismet will normally keep 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 the 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 live 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 deletion schedule for spam comments 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 use a code snippet plugin such as WPCode (recommended):

add_filter( 'akismet_delete_comment_interval', 'custom_spam_delete_interval' );

function custom_spam_delete_interval() {
	return 7;
}

For more details, just see our guide on how to add custom code in WordPress without breaking your website.

Adding the Code Snippet to WPCode

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

Expert Guides on Combating Comment Spam in WordPress

Now that you know how to change the Akismet spam commend deletion schedule, you may like to see some other articles related to combating comment spam in WordPress.

We hope this article helped you change the Akismet spam comment deletion schedule in WordPress. You may also want to see our guide on how to get a free SSL certificate or our expert pick of the best Twitter plugins for WordPress.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

1 CommentLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.