In WordPress, there is this “Trash” feature that keep your deleted articles (and comments) in the recycle bin until you go into the bin and delete them permanently. This is an useful feature as it prevents you from deleting any posts/comments accidentally. However, if you don’t have the habit of clearing your trash regularly, it would pile up with useless articles, which in turn translate to bigger database size and slower site loading.

Here’s a quick and simple way to configure your WordPress to automatically clear the trash on a regular basis:

  1. Using a FTP application (such as Filezilla), download the wp-config.php file from your server.

  2. Open the wp-config.php file with a text editor and insert the following code to the end of the file:

where ‘X’ is the interval (in days) the trash will auto-empty itself.

For example, if you want the trash to auto-empty itself every 7 days, the code will be

Disable the trash feature

In some cases, you might want to disable the trash feature altogether. You can do this by setting the number of day to 0. The code become:

That’s it.

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Our latest tutorials delivered straight to your inbox