Performance PHP Beginner

Empty the Trash Sooner

Make WordPress permanently delete trashed posts, pages and comments after 7 days instead of 30.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
wp-config.php 1 lines
define( 'EMPTY_TRASH_DAYS', 7 );

Where to add this

Recommended wp-config.php Above the line that says "That's all, stop editing!" in your wp-config.php file.

WordPress keeps trashed posts, pages, products and comments for 30 days before deleting them for good. On sites that trash a lot, such as WooCommerce stores cleaning up draft orders, that’s a lot of dead data. This constant shortens the wait.

How it works

EMPTY_TRASH_DAYS sets how many days items stay in the trash. WordPress’s daily wp_scheduled_delete task permanently removes anything older.

Things to watch

  • Setting it to 0 disables the trash completely: Delete becomes permanent straight away. That’s risky on sites with several editors.
  • Recovering a trashed item after it’s gone means restoring a backup.

How to test it

Go to Tools → Site Health → Info → WordPress Constants. EMPTY_TRASH_DAYS should show 7.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only