Custom Akismet time interval for deleting spam automatically

By default, Akismet eliminates spam comments every 15 days. Deleting spam and unapproved comments may be beneficial for your WordPress blog. Because it will optimize your website load speed and will reduce its size stripping out necessary entries from your database.

If you prefer to set a custom time interval for deleting spam comments from your blog then drop the following code snippet into your functions.php file.

As you can see the defined custom time interval in order for Akismet to remove comments is 8 days. Just give it a try and set the removal time interval to fit your needs.

functions.php
//Custom Akismet time interval for deleting spam comments
add_filter( 'akismet_delete_comment_interval', 'wph_akismet_delete_interval' );
function wph_akismet_delete_interval() {
  return 10;
}