Emptying Trash Automatically in WordPress

By default in WordPress you have the option to trash any Post, Page, Comments or even your Custom Post type item. Generally, if you trash something it remains within the "Trash" tab and then afterwards if you want, you can permanently delete them from there.

However, if you want to permanently delete items without even going to the "trash" section simply copy and paste the following snippet on your wp-config.php page.

<?php define('EMPTY_TRASH_DAYS', 0); ?>

From now on you should see "Delete Permanently" text instead of "Trash" while you hover your cursor on the top of your posts or comments (See Screenshot). You should be able to delete your items (Post, Page & Comments) permanently instead of going to the trash.

Delete WordPress Posts PermanentlyDelete WordPress Posts Permanently.

Delete After Certain Days

Now, let's not forget that if you don't delete them permanently, those trashed items would automatically be deleted after 30 days. At least that's how the default WP system works. But if you want the trashed item to be deleted (automatically) earlier, you can use following snippet on your "wp-config.php" page and define the number of days.

<?php define('EMPTY_TRASH_DAYS', 15); ?>

This snippet would allow your contents (Post, Pages & Comments) to be deleted automatically after 15 days after your send them to the trash. Hope you got the idea.



Commenting is disabled.