WordPress by default will automatically  empty your trash post from your site in 30 days. This is the normal WordPress way. But what if you do not want to delete automatically the post from trash.

You can stop automatic empty of the trash in wordpress with a simple PHP code added into the theme functions.php file. What code whould i need to add to stop the automatic empty of the trash in WordPress?

function dex_remove_schedule_delete() {
    remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
add_action( 'init', 'dex_remove_schedule_delete' );php

Also you can setup a custom number of days to delete the trash posts. Lets say you wish that your post to be automatic deleted by a period of 15 days. You can set this up real fast by posting on functions.php the following code:

define('EMPTY_TRASH_DAYS', 15);

Also you can disable this function if you do not wish even if we do not recommend this with the following code in functions.php

define('EMPTY_TRASH_DAYS', 0);


You might find interesting:   How to keep your WordPress secure