Skip to content

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.

  • Reduce database size and improve performance.
  • Free up server resources.
  • Control how long deleted items remain recoverable.
  • Disable trash entirely if not needed.
  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.