# Optimising WordPress trash settings

> Change how long WordPress keeps deleted posts, pages and comments in the trash, or turn the trash off, to keep your database lean.

Source: https://helpcenter.ruachost.com/wordpress/guides/optimizing-wordpress-trash-settings/

WordPress includes a **trash feature** that allows you to recover deleted posts, pages, comments, and attachments. By default, items remain in the trash for **30 days** before being permanently deleted. While convenient, storing trash items for too long can consume database space and affect performance. On **ruachost.com**, you can optimize these settings to improve efficiency.

## Why Optimize Trash Settings?

- Reduce database size and improve performance.
- Free up server resources.
- Control how long deleted items remain recoverable.
- Disable trash entirely if not needed.

## Steps to Optimize Trash Settings

1. **Log in to cPanel.**

   - In the **Files** section, click **File Manager**.
2. **Navigate to WordPress Directory.**

   - Typically located in `public_html`.
   - If installed in a subdirectory, go there instead.
3. **Edit wp-config.php..**

   - Right‑click `wp-config.php` → **Edit**.
4. **Add Trash Setting Line.**

   - Insert the following line before:

     ```
     require_once(ABSPATH . 'wp-settings.php');
     ```
   - Code:

     ```
     define('EMPTY_TRASH_DAYS', X);
     ```
   - Replace **X** with the number of days you want WordPress to retain trash items.

   Examples:

   - `define('EMPTY_TRASH_DAYS', 7);` → Trash items deleted after 7 days.
   - `define('EMPTY_TRASH_DAYS', 0);` → Disables trash completely (items are permanently deleted immediately).
5. **Save Changes.**

> **Note:**
- Always back up your site before editing `wp-config.php`.
- Setting `EMPTY_TRASH_DAYS` to `0` disables trash entirely, use with caution.
- Shorter trash retention improves performance but reduces recovery options.
