Hack WordPress 2.9 to automatically clear Trash after X number of days

by Vineet Sharma on May 20, 2010

in Tips and Tricks,Tutorials,wordpress




WordPress 2.9 bought with itself a great new feature called Trash. Every time a post or comment is deleted it is deposited in the Trash from where it can be recovered later if needed. Somewhat like Recycle Bin in Windows!. To remove the posts and comments permanently, you have to delete them permanently from Trash.

Delete Comments and Posts in WordPress Automatically

But, If you are one like me who use to automate tasks then here is a simple hack with which the Trash will be cleaned automatically in X number of days. Here is how you can enable it.

Go to the root of your wordpress directory and look for a file named wp-config.php. We need to add a line of code to this file to enable automatic deletion. Open this file in a text editor and paste the following line of code. Save the file and upload it to the server.

define(‘EMPTY_TRASH_DAYS’, 10 );

You can change the number of days from 10 to any number of days you want for the automatic deletion to take place.

Related:

Leave a Comment

Previous post:

Next post: