{"id":41747,"date":"2025-09-09T22:35:34","date_gmt":"2025-09-09T19:35:34","guid":{"rendered":"https:\/\/coma.lv\/2025\/09\/09\/how-to-change-the-spam-deletion-schedule-in-akismet\/"},"modified":"2025-09-09T22:35:34","modified_gmt":"2025-09-09T19:35:34","slug":"how-to-change-the-spam-deletion-schedule-in-akismet","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2025\/09\/09\/how-to-change-the-spam-deletion-schedule-in-akismet\/","title":{"rendered":"How to Change the Spam Deletion Schedule in Akismet"},"content":{"rendered":"\n<p style=\"text-align: left;\">By default, <a href=\"https:\/\/akismet.com\/\" target=\"_blank\" rel=\"noopener\">Akismet<\/a> keeps spam comments in your WordPress database for 15 days, after which they are deleted automatically. In this article we will explain how you can change this interval.<\/p>\n<h2 style=\"text-align: left;\">Why Change the Schedule?<\/h2>\n<p style=\"text-align: left;\">Akismet helps you deal with spam comments by monitoring all comments, pingbacks and trackbacks. Spam comments settle in your database, which in turn bloats the size of its backup. Deleting them reduces the size of the database. Also, if you receive thousands of comments, deleting them manually can affect the site&#8217;s performance. On the other hand, there are users who want to keep comments for later analysis.<\/p>\n<h2 style=\"text-align: left;\">Changing the Schedule<\/h2>\n<p style=\"text-align: left;\">*If Akismet marked a normal comment as spam, you can mark it as not spam, which will improve the spam detection algorithm.<\/p>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/11\/spamfolderincomments.jpg\" alt=\"WordPress\" title=\"\"><\/p>\n<p style=\"text-align: left;\">You can change the number of days the system keeps comments in your database. To do this, just paste the following code into the <code data-start=\"1502\" data-end=\"1517\">functions.php<\/code> file<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nadd_filter( &amp;#039;akismet_delete_comment_interval&amp;#039;, &amp;#039;custom_spam_delete_interval&amp;#039; );\r\n\r\nfunction custom_spam_delete_interval() {\r\n\treturn 7;\r\n}\r\n<\/pre>\n<p style=\"text-align: left;\">Change the number 7 to any number of days you need comments to be kept. Changing it to 0 will let Akismet delete all comments at the next scheduled run.<\/p>\n<p style=\"text-align: left;\">If you do not want to edit <code data-start=\"1502\" data-end=\"1517\">functions.php<\/code> manually, you can use the <a class=\"decorated-link cursor-pointer\" href=\"https:\/\/wordpress.org\/plugins\/insert-headers-and-footers\/\" target=\"_blank\" rel=\"noopener\" data-start=\"1553\" data-end=\"1582\">WPCode<\/a> plugin, which lets you add custom code snippets through the WordPress interface.<\/p>\n<h2 style=\"text-align: left;\" data-start=\"1674\" data-end=\"1698\">Checking the Changes<\/h2>\n<p style=\"text-align: left;\">You can see the changes by going to the Settings \u2013 Akismet page. Scroll down and you will see the note: <em>Spam in the spam folder older than X days is deleted automatically<\/em>, where X is the number of days you specified.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36235 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-25-061454.jpg\" alt=\"WordPress\" width=\"609\" height=\"174\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-25-061454.jpg 609w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-25-061454-300x86.jpg 300w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/p>\n<p style=\"text-align: left;\">Also note that once spam comments are deleted, you will not be able to restore them.<\/p>\n<hr \/>\n<p style=\"text-align: left;\"><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>By default, Akismet keeps spam comments in your WordPress database for 15 days, after which they are deleted automatically. In this article we will explain how you can change this interval. Why Change the Schedule? Akismet helps you deal with spam comments by monitoring all comments, pingbacks and trackbacks. Spam comments settle in your database, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37652,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1225,1407],"tags":[],"class_list":["post-41747","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-tutorials"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41747"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41747\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/37652"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}