How To Automatically Empty WordPress Trash Using Days Parameter?
October 9th, 2016 | by Ravi Chahar || 4 Comments |
When you delete any blog post then it goes to the trash section. You can empty WordPress trash manually by clicking on the “delete permanently” option.
But what would you do to set the number of days to keep the post in the trash folder? How would you set the maximum number of days for the WordPress trash to get emptied?
In this tutorial, I am going to provide you the code which can help you to automatically empty WordPress trash.
Use EMPTY_TRASH_DAYS To Empty WordPress Trash.
In WordPress, there is a default code which keeps the posts in the trash folder for 30 days. To change the default value, you have to edit the wp-config.php file.
The code is.
But if you want to automatically empty WordPress trash in a few days then you can set it.
Step 1:- Login to your cPanel and open the file manager.
Step 2:- Search for the wp-config.php file and click to edit it. Add the below-written code.
After adding this code, the trash folder will get emptied after every 10 days. It will provide you enough time to restore your post.
And if you want to change the frequency then just replace the figure in the code. You can set it from 1 to 29. But for the better site handling “10” days are perfect.
Sometimes you may accidently delete any blog posts from your published posts then it goes to the trash folder and you can restore it.
But if you minimize the empty days then maybe you won’t be able to restore the blog post.
Can You Now Set The Number To Empty WordPress Trash?
Most of the WordPress users get fed up with the load in the trash section. They try to manage it but for a bigger website, it’s a kind of hard to delete each and every post manually.
So to get rid of this problem, you should set the number of days to keep the posts in the trash folder. After that, all the posts will get deleted.