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

How to automatically empty the Trash in WordPress

This guide explains how WordPress empties its Trash by itself, and how to change how many days it waits.

WordPress2 min read9 steps

What is the Trash?

When you delete a post, page or comment in WordPress, it does not vanish right away. It goes to the Trash, like a recycling bin on your computer. You can bring it back from there if you change your mind.

By default, WordPress empties the Trash by itself after 30 days. Items older than that are removed forever. If you want a shorter or longer time, you can change it. You do this with a small piece of code in the wp-config.php file. That file holds the main settings of your WordPress site.

Empty the Trash by hand

  1. Go to Posts, then All Posts.
  2. Click the Trash link above the list.
  3. Click Empty Trash.

Warning: this deletes the items forever. You cannot undo it. Check the list first.

Pages and comments have their own Trash links in Pages and Comments.

Change the number of days

Warning: a typing mistake in wp-config.php can break your site. Take a backup of the file before you start.

  1. Log in to your hosting control panel and open File Manager. You can also use an FTP program.
  2. Open the folder where WordPress is installed. This is often public_html.
  3. Right-click wp-config.php and choose Edit.
  4. Find the line that says /* That's all, stop editing! Happy publishing. */.
  5. Just above that line, add this:
    define( 'EMPTY_TRASH_DAYS', 7 );
    This tells WordPress to empty the Trash every 7 days. Change the number to the days you want.
  6. Click Save Changes.

Turn the Trash off completely

If you set the number to zero, items are deleted at once and skip the Trash. There is no way back.

define( 'EMPTY_TRASH_DAYS', 0 );

This line makes every delete permanent. Only use it if you are sure.

Use a plugin instead

A plugin is an add-on for WordPress. If you do not want to edit files, you can use a cleanup plugin. Go to Plugins, then Add New, and search for a database cleanup or trash plugin. Many let you set a schedule. Read the plugin settings carefully before you run it.

Tip: A shorter time keeps your database tidy. But a longer time gives you more days to rescue something deleted by accident. For most sites, the 30-day default is fine.

Quick recap

  • Deleted items go to the Trash first. WordPress empties it after 30 days.
  • Change the time with EMPTY_TRASH_DAYS in wp-config.php.
  • A value of 0 turns the Trash off, and deletes cannot be undone.
  • Always back up before you edit the file.