I have a client who wants to use the trash feature, but keep items in there indefinitely (I have no idea why, but they insist on it).

From reading this codex article on the trash status, I see that you can set the EMPTY_TRASH_DAYS constant to zero. But it says that this will disable trash functionality altogether. I don't want to do this. I just want to disable the auto-trash emptying.

Is there any way to do this? Or am I stuck with just entering some huge number for the EMPTY_TRASH_DAYS value?

2 Answers 2


My guess is - yes, you are stuck with exactly that.

Checks for EMPTY_TRASH_DAYS seem to be hardcoded as condition for switching interface between trash and delete in several places.

  • Thank you for the help. Question though--I see that trash collection is scheduled as an event in wp-admin/admin.php (wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');). Do you think it's possible to simply unschedule the event at some point? Maybe on every admin init? Or do you think that's just fighting against the system?
    – MathSmath
    Jan 25, 2011 at 20:14
  • @MathSmath hmmm... I don't think it's worth it to fight with schedule (schedules are persistent = messy db reads/writes), but you can try to remove wp_scheduled_delete() function from wp_scheduled_delete hook. I am not sure about at what hook/stage it would be best for that in cron environment.
    – Rarst
    Jan 25, 2011 at 20:29

You can do the following:

  • Set EMPTY_TRASH_DAYS to a very high number. E.g.: define( 'EMPTY_TRASH_DAYS', 1000000 );

  • Or remove the wp_schedule_delete action:

    function my_remove_schedule_delete() {
        remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
    add_action( 'init', 'my_remove_schedule_delete' );
  • Thank you for the answer! I actually worked it out with Rarst just a few minutes before you posted. I'm giving you a vote and Rarst the answer. Thanks again!
    – MathSmath
    Jan 25, 2011 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.