Skip to content
All writing

Change or deactivate WordPress's automatic empty trash

Disable the automatic emptying of the WordPress trash via EMPTY_TRASH_DAYS or a hook in your theme's functions.php.

#snippetswordpressphp

Not using the WordPress trash? Add this line to wp-config.php at the root of your WordPress installation to disable the feature altogether.

define('EMPTY_TRASH_DAYS', 0); // The 0 here is the number of days for WordPress to keep a trashed item before deleting it.

No need to use a plugin for this, but if you ever find yourself in a situation where you have to: Change Empty Trash Time.

By default, WordPress automatically deletes posts in the trash after 30 days. If you'd like to keep using the trash but want to disable the automatic deletion, add this hook in your theme's functions.php (use a child theme!):

function remove_scheduled_delete() {
    remove_action('wp_scheduled_delete', 'wp_scheduled_delete');
}

add_action('init', 'remove_scheduled_delete');

Get new posts by email

New writing in your inbox. Unsubscribe anytime.