# Empty the Trash After 7 Days

> Permanently removes trashed posts, pages and comments after 7 days instead of 30, keeping the database lean.

- Type: PHP
- Runs: Run everywhere
- Category: [Performance](https://wpide.com/library/category/performance/)
- Tags: performance, database, trash
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/empty-trash-sooner/

## Code

```php
// Days before trashed items are deleted for good (0 disables the trash entirely, so avoid it).
if ( ! defined( 'EMPTY_TRASH_DAYS' ) ) {
    define( 'EMPTY_TRASH_DAYS', 7 );
}
```

## Notes

Has no effect if EMPTY_TRASH_DAYS is already set in wp-config.php.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Empty the Trash After 7 Days" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
