We receive a number of requests from customers using our WordPress Hosting service for ways to delete entries in the trash of WordPress automatically. So with a view to helping them and others, here is a simple method to achieve the task and free the space from the server.
Basically, in WordPress the wp-config.php function is responsible for controlling the time-frame for which the data would be held in wordpress trash. Editing the period can help you reduce the number of days for the data to be retained in WordPress. This would further free you from the need to check the trash section before you could manually use the ‘Empty Trash’ button.
Follow the below steps to tweak the default configuration settings in WordPress:
WordPress sets a default period of 30 days until data is retained in Trash. If you view the wp-config.php file you can find the following
define( ‘EMPTY_TRASH_DAYS’, 30 ); // 30 days default
Editing Trash settings in WordPress
You can change the default settings by defining the number of days for WordPress to automatically delete posts in trash.
For example : If you want the system to automatically delete entries in trash after 5 days, you can edit the entry as :
/* Automatically delete WordPress trash after 5 days */
define( ‘EMPTY_TRASH_DAYS’, 5 );
How to stop WordPress from accumulating posts in Trash ?
To disable trash, all you need to do is set the number of days to zero.
BUT, we wouldn’t recommend you to have such a setting enabled in your WordPress installation as you may end-up losing important entries which cannot be retrieved incase you need it. Therefore, avoid keeping the value to zero.
If you need any assistance with making the changes, you may either contact your website developer OR contact us.