Wordpress 30 wordpress trash auto delete
How To Optimize WordPress Trash Settings
wordpress how to save trash permently
wordpress trash auto delete



What is Trash in WordPress?

When you delete a post, page, or a comment in WordPress, it is marked as trash.



You can see the trashed posts or comments by clicking on the Trash link when viewing posts, pages, or comments.
By default, these items will remain there for 30 days. After that, WordPress will automatically delete them permanently.
You can override the automatic process by going to trash and deleting the items manually by clicking on the delete permanently link.




But what if you dont want WordPress to delete items from trash? Or maybe you want WordPress to automatically delete items sooner or later than 30 days.
Lets take a look at how to limit or disable automatic WordPress empty trash feature.

Stopping WordPress from Automatically Emptying Trash

Do you want to stop WordPress from automatically deleting items from trash? Here is what you need to do.
Simply add this little code snippet in your themes functions.php file or a site-specific plugin.

:
function wpb_remove_schedule_delete() {
    remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
}
add_action( 'init', 'wpb_remove_schedule_delete' );
This code simply removes the action that deletes trashed items when their time is up.
Now when you send an item to trash, it will remain there until you go to trash and manually empty the trash.

Changing When to Empty Trash in WordPress

As we mentioned earlier, WordPress automatically empty trash after 30 days. You can change this to any number of days you want.
Simply add the following line of code in your wp-config.php file just before the line that says Thats all, stop editing! Happy blogging.

:
define('EMPTY_TRASH_DAYS', 7);
This line changes the trash emptying schedule to 7 days. You can change 7 to any number of days that you want.

-----------------------------------------------------
plugin Trash
-----------------------------------------------------



https://wordpress.org/plugins/change...ty-trash-time/