What is the WordPress trash?
When you delete a post, page or comment, WordPress does not erase it right away. It moves it to the trash first. That is like a recycle bin on your computer. If you change your mind, you can restore the item.
By default, WordPress empties the trash by itself after 30 days. A trash full of old items makes your database bigger, so some people want it cleared sooner.
Empty the trash by hand
- Log in to your dashboard.
- Go to Posts, then All Posts.
- Click the Trash link above the list.
- Click Empty Trash.
Do the same for Pages and Comments.
Change how many days WordPress keeps trash
You do this in the wp-config.php file. This file holds your main WordPress settings.
- Open File Manager in your control panel.
- Go to the folder where WordPress is installed. This is often
public_html. - Right-click
wp-config.phpand choose Edit. Make a copy of the file first. - Add this line above the text "That's all, stop editing".
This tells WordPress to empty the trash every 7 days. You can use any number.define( 'EMPTY_TRASH_DAYS', 7 ); - Click Save Changes.
Skip the trash completely
You can set the number to zero. Then deleted items vanish right away with no way back.
define( 'EMPTY_TRASH_DAYS', 0 );
This turns the trash off. Use it only if you are sure.
If you have more than one line for it
Do not add the same line twice. If EMPTY_TRASH_DAYS already exists, change the number in that line instead.
Check that it works
- Delete a test post.
- Look in the trash. The post should wait there.
- After the number of days you set, WordPress clears it. This clean-up runs when your site gets visits.
Quick recap
- Deleted items go to the trash for 30 days by default.
- Empty the trash by hand under Posts, then Trash.
- Add
EMPTY_TRASH_DAYStowp-config.phpto change the time. - A value of 0 skips the trash and deletes at once.