Automatically empty WordPress trash can

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.

  1. Open wp-config.php file
  2. 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”.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

0 thoughts on “Automatically empty WordPress trash can

Leave a Reply

Your email address will not be published. Required fields are marked *