How to automatically empty trash in WordPress

The Trash feature was added to WordPress in version 2.9. Trash in WordPress is similar to Recycle Bin in Windows. When you delete an item, it is placed in Trash Folder for 30 days. After 30 days,it is deleted permanently. In order, to change the number of days after which items will be deleted permanently, you need to paste following code in wp-config.php file, which is located in the root directory of your WordPress installation.

//Automatically Empty Trash
define( 'EMPTY_TRASH_DAYS', 7);

7 are the Number of days to deleted the item. You can change this to 7 to 1,2,3 or anything you want. You can also use disable trash feature by setting the number of days to Zero.

//Permanently Delete Posts
define( 'EMPTY_TRASH_DAYS', 0);

See Also: Log in a WordPress user programmatically


Leave a Comment.