Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Empty the WordPress trash automatically

This guide shows how to change how long WordPress keeps deleted items, and how to empty the trash by hand.

WordPress2 min read12 steps

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

  1. Log in to your dashboard.
  2. Go to Posts, then All Posts.
  3. Click the Trash link above the list.
  4. Click Empty Trash.

Do the same for Pages and Comments.

Warning: Items removed from the trash are gone for good. Take a backup if you are unsure.

Change how many days WordPress keeps trash

You do this in the wp-config.php file. This file holds your main WordPress settings.

  1. Open File Manager in your control panel.
  2. Go to the folder where WordPress is installed. This is often public_html.
  3. Right-click wp-config.php and choose Edit. Make a copy of the file first.
  4. Add this line above the text "That's all, stop editing".
    define( 'EMPTY_TRASH_DAYS', 7 );
    This tells WordPress to empty the trash every 7 days. You can use any number.
  5. 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

  1. Delete a test post.
  2. Look in the trash. The post should wait there.
  3. 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_DAYS to wp-config.php to change the time.
  • A value of 0 skips the trash and deletes at once.