How to Automatically Empty WordPress Trash including deleted posts, pages, attachments & comments from the WordPress trash bin? A small tweak for optimum performance & avoiding bloated WordPress installation with useless data.

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

This function will automate process of deleting WordPress Trash & you will not have to press ‘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 disable trash set the number of days to zero.

Note: WordPress will not ask with confirmation prompt when someone clicks on “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 & restore important item from WordPress trash & You don’t have to press empty trash button again everywhere in posts, comments & pages. It will be peace of mind & security that your WordPress Installation is Optimised & not bloated with useless data.


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

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