Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  WordPress FAQ  >  How To Automatically Delete Trash In WordPress?
Top Scroll

How To Automatically Delete Trash In WordPress?

 2 min

At times, there are a huge number of posts in Trash and you might want to delete all of them at once. In WordPress, the ‘wp-config.php’ function controls the time frame for which the data is stored in the WordPress trash folder. By editing the time frame in the ‘wp-config.php’ function you can reduce the number of days for which the data is stored in the trash folder. If you do this, there will be no need to check the trash folder for deleting the posts.

Here are the necessary steps for editing the time frame for wp-config.php function:

WordPress sets a default time frame of 30 days for the data to be retained in the trash folder. If you check the wp-config.php file, you will come across the following:

define( ‘EMPTY_TRASH_DAYS’, 30 ); // 30 days default

You will have to change the time frame mentioned above. For instance, if you would like the WordPress system to delete the trash posts in 10 days, you can edit the entry mentioned above:

/* Automatically delete WordPress trash after 10 days */

define( ‘EMPTY_TRASH_DAYS’, 10 );

In the example given above, if you define the number of days to 0, WordPress posts will stop accumulating in the trash folder. This is not recommended as there is a chance that you might lose some of the important posts. Therefore, it is advisable to set the number of days less than 30 but not 0.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.