How to Automatically Empty WordPress Trash.

This wp-config.php function controls the days before WordPress permanently deletes posts, pages, attachments & comments from the trash bin.

This function will automate the process of deleting WordPress Trash & you will not have to press the ‘Empty Trash’ button again for your installation.

Default WordPress Trash Settings:
The default is 30 days.

define( 'EMPTY_TRASH_DAYS', 30 ); // 30 days default

Disable WordPress Trash & Delete things immediately:
To turn off trash, set the number of days to zero.

Note: WordPress will not ask for a confirmation prompt when someone clicks the “Delete Permanently” WordPress User Interface (UI) button.

define( 'EMPTY_TRASH_DAYS', 0 ); // Disable Trash & Delete Immediately Without Prompt (Zero days)

Recommendations & Suggestions:
I would suggest defining days to 10. You will have enough time to undelete and restore essential items from WordPress trash, and you won’t have to press the empty trash button again everywhere in posts, comments, and pages. It will be peace of mind and security that your WordPress Installation is Optimised and not bloated with useless data.

/* Automatically delete WordPress trash after 10 days */
define( 'EMPTY_TRASH_DAYS', 10 );

I hope this information helps,

Thanks & Regards
Mandar Apte

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply