How to limit the automatic WordPress empty trash feature in order to reduce the size of your database

Every time you delete an item in WordPress such as a post, page, or comment it gets marked as trash. Until WordPress automatically deletes your trash every 30 days by default these items are increasing the size of your database. By allowing WordPress to automatically delete your trash sooner, you will help decrease the size of your database from unnecessary bloating. In this tutorial we will teach you how to limit the automatic WordPress empty trash feature in order to reduce the size of your database.

Limit the automatic WordPress empty trash feature by editing the wp-config.php file

In order to limit the automatic WordPress empty trash feature you will need to edit the wp-config.php file located in your WordPress site’s root folder. Download and open the wp-config.php file, copy and paste the code below just before the line that says ‘That’s all, stop editing! Happy blogging.’ After you save your changes and upload the wp-config.php file back to your server WordPress will now automatically empty the trash every 5 days, you can change this number to any number of days that you want.

PHP

define('EMPTY_TRASH_DAYS', 5 );

Troubleshooting

If you are having problems getting this tutorial to work please reread the tutorial and try again, if you still cannot get it to work please leave us a comment below and we will respond as soon as possible. Please do not email us with problems regarding this tutorial, only comments will be responded to.