How to Delete WordPress Trash Daily: Automated Process

Do you wish to delete and empty WordPress Trash daily? We delete many spam WordPress comments everyday and WordPress Trash fills up really fast. Often the Trash accumulates thousands of comments. How to empty Trash automatically?

Empty wordpress thrash

When Does WordPress Trash Get Deleted?

WordPress will permanently delete posts, pages or comments in the trash after 30 days automatically. So dont worry about accumulating thousands of Trash files.

How to empty WordPress Trash Daily

You can decide when to empty the WordPress trash by adding this code to the wp-config.php file in your WordPress root directory.

define('EMPTY_TRASH_DAYS', 1 );

The 1 in the code signifies you want to empty the trash everyday. If you use a value like 5, it will empty trash every 5 days. If you set to 0, the trash functionality will be disabled and the ‘Delete Permanently’ button will appear instead of ‘Trash’ button and then you can delete posts and comments permanently without any alert.

Warning: Remember to always backup wp-config.php file before editing it or your blog function may be disrupted.

Now never click Empty Trash ever again.

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.