If you work on your PC, you’re quite aware of Recycling bin. Once you delete a file, it will go directly to trash and let you restore it or delete permanently if you don’t need that file anymore. After WordPress rolled out version 2.9, there was a similar feature introduced which made all of your posts appear in the trash can after you delete an article.
While this might come in handy if you accidentally delete a post, it might get annoying if you’re not using the feature at all. After a while, you’ll end up with a bunch of posts still sitting in the trash can. Yeah, since you don’t have to actually pack the garbage bag and carry it to a container, it isn’t that hard to click on the Trash link on top of your posts and empty the virtual bin. But if you like to keep you work environment clean and tidy and you don’t want to wait a month for your WP to do that automatically, you might want to tell your WordPress to clean up more frequently.
Making this work is really simple so you won’t even have to think about installing plugins. All you need is a one line of code.
- Open wp-config.php file
- Copy and paste the following code:
define('EMPTY_TRASH_DAYS', 2 );
All you have to change, if you want to, is the last number in the code. That number tells WordPress how often to clean the trash. In this case, WordPress would delete every item in trash can every two days. Change the number to whatever you think it’s best for your website and enjoy a clean trash can.
Want to disable the trash feature entirely? Simply use “0” as the last number in the code:
define('EMPTY_TRASH_DAYS', 0 );
After you do this, “(Move to) Trash” option will be changed to “Delete Permanently”.