X
    Categories: Tutorials

Changing the WordPress default empty trash time

Trash in WordPress is great. If you accidentally delete a post or page instead of being permanently deleted it is simply moved to the trash folder where it can be recovered if necessary. By default the trash folder auto empties everywhere 30 days but this can be changed in the wp-config.php file.

define( 'EMPTY_TRASH_DAYS', 15 );

Or, if you wish to disable auto empty all together just set it to 0

define( 'EMPTY_TRASH_DAYS', 0 );

A little extra something I didn’t know about, you can still enable the trash option for media items. This was officially deprecated in WordPress 2.9 but by adding this to your config.php file you can re-enable it:

define( 'MEDIA_TRASH', TRUE );

The only slight snag is that images moved to the trash can still be accessed on your site through their URL, probably why it was deprecated in the first place. So if you do delete something make sure it’s not linked to on your site.

WARNING: I don’t advocate use of MEDIA_TRASH unless you know what you’re doing. It has been deprecated meaning it may be removed at any time in a future update.

Edward :