What's WP
Find Everything Related to WordPress - Best Tutoriasl on WordPress!
How to Control the WordPress "Automatic Delete Trash" Feature

How to Control the WordPress “Automatic Delete Trash” Feature

Since the version 2.9, WordPress have been coming with a helpful trash feature. When you delete the useless posts, pages or comments, they are categorized as “trash” in WordPress dashboard, and they will remain in trash until WordPress deletes them automatically after 30 days.

During the 30 days, you can manually delete the trash permanently, or restore the posts, pages and comments that have been deleted accidently.

WordPress Trash

The default configurations of WordPress “automatic delete trash” feature are good to use for most people. However, you may want to take full control and do things like shortening the days for trashed posts to remain, disable the automatic deleting, etc. If you have any needs like this, just follow the very simple tutorials below to achieve what you want.

Lengthen or Shorten the Days for WordPress to Delete Trash

By default, WordPress deletes the trashed posts, pages and comments permanently from the database after 30 days of their deletion. However, WordPress indeed gives you the freedom to control the frequency, so you can automate the trash emptying to perform daily, weekly, per 10 days, or with any other frequency you want.

No plugin is needed for changing the days, because all you need to do is to locate the wp-config.php file in your WordPress directory, open it in a text editor, and then add the following line of code before the “Stop Editing” line.

Change the Days for WordPress to Delete Trash

The number “1” in the example above indicates that trashed content will be deleted one day after it is moved to trash. Of course, you can change the number to whatever you like. For example, if you want WordPress to empty trash after a week, then replace “1” with “7”. The same change comes to “10” or any other number of days.

Prevent WordPress from Deleting Trash Automatically

Sometimes you may want to disallow WordPress to delete trash automatically because you would like to do everything manually to prevent the mistakenly trashed posts from being deleted.

In such a case, you can remove the WordPress deleting trash action by adding the following code in the functions.php file of your theme.

Prevent WordPress from Deleting Trash

This function stops the scheduled trash deleting action from operating, so the trash posts will remain even if the configured deletion days have passed by already. Therefore, posts, pages and comments stay in trash until you delete them or empty trash manually.

Disable WordPress Trash Feature

Besides the two occasions discussed above, there is also a rare case that you may want to disable the WordPress trash feature temporarily. This usually happens when you are working on a staging site or a local development environment. If you create a large number of posts or comments for testing purpose, you may prefer to delete posts directly from the post list instead of moving them to trash and then spending time deleting them again.

If this is what you want, add the code below to the wp-config.php file.

Disable WordPress Trash Feature

With this code, the trash feature is disabled for all your posts, pages, comments and custom post types. You will get a link “Delete Permanently” instead of the ordinary “Trash”. You can then delete posts immediately.

Delete Permanently

Note that we don’t recommend disabling the trash feature on any production site. Even if on a staging site, you should be careful because without the trash feature, you don’t get a chance to think twice about the content you delete.

Automatically Empty WordPress Trash

It should be noted that there is a solution for people who don’t like the Trash feature. These administrators can change the integer to “0” and avoid permanent deletion of the posts from the Trash menu.

As the Trash feature is available in WordPress versions higher than 2.9, the above-mentioned procedure is suitable for bloggers whose site runs on recently updated WordPress versions. Users whose websites are running on WordPress versions of 2.8 can not avail this feature from the core. However, they can avail the alternate method, i.e. using plugins for deleting Trash automatically.

There are tremendous numbers of plugins that can be used to customize the time interval for deleting the trash from the WordPress site automatically. Some of the most efficient plugins that fall into this category are Trash Emptier and RJ Quick Empty Trash. Using these plugins is as easy as any other simplified plugin for WordPress. The administrator only needs to install the plugin and customize it manually to set the automatic cleaning of Trash.


Joyce is a professional writer & SEOer who loves trying new things and sharing the experience through blogging. She loves clean design, playing with different WordPress themes, SEO, etc. Very often, you could find her in various WordPress event as invited speakers.