Disable or Limit Automatic Empty Trash in WordPress

Disable or Limit Automatic Empty Trash in WordPress

In WordPress, Whenever you delete a Post or comments it will automatically go to trash by default. The posts and comments will remain for 30 days in the trash so that you can restore in that specific time if required else it will be deleted permanently after 30 days of time. In this article, we will show you how to Disable or Limit Automatic Empty Trash in WordPress.

What is Trash in WordPress?

When you delete any Page, Post or comment in WordPress it will be marked as trash by default. All the trashed items will remain for 30 days and WordPress will auto delete them for permanent and you will not be able to recover them even if you need.

Trash links on Posts screen

There is an option provided by WordPress where you could manually go and delete each post from the Trash or empty the complete trash at once.

But what if you do not want to delete these items automatically or if you want to extend the time from 30 days to 100 days? Take a look at the below options on how to disable or limit the automatic trash empty feature by WordPress.

Stop WordPress from Emptying the Trash Automatically

If you would like to completely stop the WordPress from deleting the items from trash then Login to FTP account and navigate to the themes folder. Find function.php file in the themes folder and add the below code.

The above code will remove the action that deletes the trash items at scheduled date. Until and unless you manually delete the post it will remain forever in the trash list and you can restore it at any time in case if you need.

Increase or Decrease the Empty Trash Time in WordPress

We know that WordPress will empty the trash automatically after 30 days. In case if you need to change this schedule to any other number of days you could do it by editing the wp-config.php file.

Simply add the following line of code in your wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’

define('EMPTY_TRASH_DAYS', 15);

The above code changes the schedule of auto deletion of trash items from 30 days to 15 days. You could set any other number you want here.

Read Also Disable WordPress Login Hints in Login Error Messages

Disabling the Trash Feature in WordPress

Disabling the trash is not recommended in WordPress. It’s a very good feature provided by WordPress and it really comes handy if you delete any posts accidentally. It will be easy to recover in no time.

Trash feature disabled in WordPress

But if you feel that you don’t need this functionality at any cost and you rather delete all the items or posts permanently in WordPress then go for this option.

Simply add the following line of code in your wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’

define('EMPTY_TRASH_DAYS', 0);

Adding this line of code in wp-config.php will remove the Trash feature in WordPress and any Posts, Pages, Comments, Custom Post types you delete will be permanently deleted.

You may also like...

Leave a Reply

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

CommentLuv badge