By default WordPress will automatically delete anything added to trash after 30 days.
To disable the built in WordPress auto trash feature, you can use the following scripts:
Either disable the scheduled delete job as triggered by the wp_scheduled_delete() function.

  1. // Removes the job to delete from trash after 30 days.
  2. function my_remove_schedule_delete() {
  3. remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
  4. }
  5. add_action( 'init', 'my_remove_schedule_delete' );

Of you could just extend the days to an much higher number. The method above is probably the best, however it might be worth also including this as a fall back.

  1. // As a fallback, changes removal of trash after 30 days to infinite
  2. define( 'EMPTY_TRASH_DAYS', 1000000 );

Rather than extending / disabling the trash feature, you could just disable it, by setting the total days to 0. This will mean that when you click to delete, it skips the trash and is permanently deleted straight away.

  1. // Disables Trash - and permanently deletes post / image
  2. define( 'EMPTY_TRASH_DAYS', 0 ); // Zero days

Leave a Reply

Your email address will not be published. Required fields are marked *