You are here: Home » WordPress » Delete spam comments after three (3) days
No spam

Delete spam comments after three (3) days

Here is how to change Akismet interval to three days instead of 15 days for deleting spam comments using the akismet_delete_comment_interval filter.

Normally in WordPress, Akismet deletes spam comments after 15 days, which may be fine with you or not. If you’d like to change the interval in which Akismet deletes spam comments, you can add the following code to your functions.php file:

/**
 * Filter to change Akismet interval to delete spam comments after 3 days
 * Support/Donate: https://www.paypal.me/jreilink
 */
add_filter( 'akismet_delete_comment_interval', 'custom_delete_spam_interval' );
function custom_delete_spam_interval() {
	return 3;
}

This changes Akismet’s interval to 3 days, after which comments held as spam are automatically deleted. You need to select Always put spam in the Spam folder for review option, as shown below:

Akismet: Spam in the spam folder older than 3 days is deleted automatically

Did this post helped you solve a problem? Or dit you find it interesting? Support Sysadmins of the North with a direct donation via Paypal of by bank wire transfer IBAN: NL31 ABNA 0432217258 (Jan Reilink). Just $ 5,- or € 5,- is more than enough, thanks!

Support SAOTN.ORG


4 thoughts on “Delete spam comments after three (3) days”

  1. Hello,

    I tried this on my blog but it didn’t work. Can we say that this code is not working anymore? I guess this doesn’t work in WordPress 5 and above versions. Would you check?

    1. Hello Hakan, thank you for your comment. I added a screenshot to the post showing the ‘akismet_delete_comment_interval’ in effect. See for your self and notice the interval difference in Akismet’s configuration with and without the interval function active. You do need to select the Always put spam in the Spam folder for review option for this to be active.

    2. Hello Hakan,
      I’ve Tested This Code Today On The Latest Verison Of WordPress AND Its Working!
      I Even Changed 3 Days to Only 1.

      Thanks

Leave a Comment

Your email address will not be published. Required fields are marked *

35 queries, took 0.650 seconds running PHP version 7.4.8