Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Backups & maintenance · Guide

How to Clean Up an Old WordPress Site

How to Clean Up an Old WordPress Site

Short answer

To clean up an old WordPress site, back up the whole site first, then remove unused plugins and themes, delete old post revisions, clear spam comments, and empty the trash. Clean up unattached media, clear expired transients, and reduce autoloaded options left by deleted plugins. Check the site and Site Health after each step.

Key takeaways

  • Back up the whole site before a cleanup, since a wrong delete can break a page or a feature.
  • WordPress stores every post revision by default, so cap new ones with WP_POST_REVISIONS in wp-config.php.
  • Items in the trash are deleted for good after 30 days by default, or sooner with EMPTY_TRASH_DAYS.
  • Site Health flags autoloaded options above 800 KB, which usually come from plugins you deleted long ago.
  • WordPress may create 50 transient options in a week, so schedule a weekly cleanup to keep them down.

What should you do before you clean up a WordPress site?

Back up the whole site first, then remove one kind of clutter at a time and check the site between steps.

A cleanup deletes data, and a wrong delete can break a page or a feature. WordPress.org advises backing up your database regularly and always before an upgrade, and the same care applies before a cleanup. A full backup means any mistake can be undone in minutes.

Work through the clutter in order, starting with the safest items. The table below shows what is safe to remove and what to check first.

ClutterSafe to removeCheck first
Unused plugins and themesYes, after deactivatingNothing on the site still uses it
Post revisionsYes, keep a few recent onesThe post itself stays untouched
Spam commentsYesReal comments are not mixed in
Expired transientsYesThe feature that made them still works
Unattached mediaOnly with careThe file is not used in a page or post

Our guide to how to back up WordPress explains how to make that backup if you have not made one yet.

How do you remove unused plugins and themes?

Deactivate a plugin you no longer use, check the site still works, and then delete it from the Plugins screen.

Open Plugins > Installed Plugins in the admin area. Deactivate each plugin you do not use, then use the Inactive filter to list them all and delete them in bulk. A deactivated plugin still sits on the server, so deleting is the step that counts.

Do the same for themes under Appearance > Themes. Keep the theme your site uses and its child theme if you have one, and delete the rest. If you use a child theme, do not delete its parent theme, since the child theme needs the parent files to work.

Deleting a plugin does not delete its data. The WordPress.org page for the Attic cleanup plugin notes that every plugin you have ever installed leaves something behind, and that deleting the plugin does not delete its data. Section 6 and 7 below cover that leftover data.

If your plugin list keeps growing, read how many plugins is too many for WordPress to judge how many your site should carry.

How do you delete post revisions and limit new ones?

Delete old revisions with a cleanup plugin, then cap new ones in wp-config.php so they stop piling up again.

Every time you update a post, WordPress saves a copy of the previous version as a revision. By default it stores every revision, since the WP_POST_REVISIONS setting defaults to true, according to the WordPress.org revisions documentation. A post edited 50 times can hold 50 revisions in the database.

WordPress has no built-in screen for deleting revisions, so use a cleanup plugin for the job. WP-Optimize cleans post revisions, auto draft posts, trashed posts, spam and trashed comments, as its WordPress.org plugin page explains. Install it, open its Database tab, tick the revision option, and run the cleanup.

To stop the pile from growing back, add a limit to wp-config.php. WordPress.org gives this example: define( 'WP_POST_REVISIONS', 3 );.

A number above zero keeps that many revisions plus one autosave per user for each post, and old revisions are deleted on the next update. Setting the value to false stores no revisions at all, apart from the single autosave.

Autosaves are separate from revisions. WordPress.org notes there is at most one autosave per user for any given post, and new autosaves overwrite old ones, so they do not grow the database the way revisions do.

How do you clear spam comments and empty the trash?

Delete spam comments in bulk from the Comments screen, then empty the trash so trashed posts and comments leave the database for good.

Open Comments in the admin area and filter by Spam. Select the spam comments and delete them in bulk. Check the Pending list too, since real comments sometimes land there by mistake, and spam sometimes hides among them.

Trashed posts, pages and comments stay in the database until they are deleted for good. By default, items in the trash are permanently deleted after 30 days, according to the WordPress Codex. You can shorten that period with the EMPTY_TRASH_DAYS constant in wp-config.php, for example define('EMPTY_TRASH_DAYS', 7);.

To empty the trash now, open the Trash view for posts, pages or comments and click Empty Trash. Once an item is permanently deleted it is gone for good, so check the list before you confirm.

How do you clean up the media library?

Remove files you no longer use, starting with the largest ones, and check that each file is truly unused before you delete it.

Open Media > Library and switch to list view to sort by file size. Large images and videos usually account for most of the space. WordPress creates several sizes for every image you upload, so one photo can mean half a dozen files on the server.

Do not delete a file just because WordPress lists it as unattached. A file can be in use on a page or in a theme file while WordPress still lists it as unattached, so check where it appears before you remove it. When in doubt, leave the file in place.

For images you keep, smaller files load faster. WP-Optimize notes that WebP can achieve up to 34% smaller file sizes compared to JPEG and up to 26% compared to PNG, and its image tools can convert and compress your library in bulk.

While you review old posts for unused images, you may find content worth updating or removing. Our guide to how to update old posts for SEO covers how to handle that content once you find it.

How do you reduce autoloaded options in the database?

Find the largest autoloaded options in Site Health, work out which plugin left them behind, and remove or switch off only the ones that belong to plugins you no longer run.

WordPress stores most settings in the options table, and autoloaded options load on every single page request. The WordPress.org page for the Attic plugin states that Site Health flags autoloaded options against an 800 KB limit, and that WordPress loads that leftover data on every page.

Start in Tools > Site Health > Status and look for the autoloaded options warning, which shows the count and total size. If the total is under 800 KB, autoload is not your problem, and you can skip this section.

The bloat usually comes from plugins you removed long ago, since nothing cleans up their options on its own. The Attic plugin page explains that its scan lists each large option with the plugin it belongs to and whether that plugin is still installed. Remove the options left by deleted plugins first, and leave any option that belongs to a plugin you still run.

Never delete rows from the options table by hand without a current backup. Flipping autoload off for a heavy option is safer than deleting it, since the data stays in the database in case a plugin needs it. Our guide to how to optimize the WordPress database covers the database tools that handle this job.

How do you clear expired transients and orphaned data?

Clear expired transients with a cleanup plugin, then look for orphaned tables and meta rows left by plugins you deleted.

Transients are short-lived cache entries that WordPress and plugins store in the database. The WP-Optimize plugin page notes that WordPress may create 50 transient options in a week, and that scheduling a weekly cleanup keeps them from building up. Open the Database tab in WP-Optimize and tick the transient option to clear the expired ones.

Orphaned data is harder to spot. The Attic plugin page lists what a scan can find: tables no installed plugin claims, post and comment meta whose parent row is gone, scheduled jobs with no code behind them, and expired cache rows. Deleting a plugin leaves these behind, and they add up over years.

Handle orphaned tables with care. Some plugins share tables, and some keep data you would want back if you reinstall.

A tool that renames tables first, such as Attic, lets you check the site still works before the data is removed for good. Its quarantine window is 30 days by default, so anything you remove can be restored within that time.

How do you check the site after a cleanup?

Open the home page and a few key pages, log in to the admin area, and run Site Health again to confirm nothing broke.

A cleanup touches many parts of the site at once, so check it in the same order you cleaned it. Load the home page, a blog post, a product or service page, and any page with a form. Log in to the admin area and confirm the dashboard loads without errors.

Then open Tools > Site Health again. Our guide to how to use Site Health in WordPress explains what each warning means and which ones matter most. If the autoload warning is gone or smaller, the database cleanup worked.

If a page breaks, restore the backup you made at the start rather than guessing at a fix. A restore takes minutes, while hunting for a deleted option can take hours. If the site feels slow after the cleanup, read how to find slow plugins in WordPress to look for a plugin that is still loading more than it should.

How often should you clean up a WordPress site?

Clean up a busy site every month and a quiet site every three months, with a quick plugin and theme review each time you update.

WP-Optimize can schedule cleanups daily, weekly, fortnightly or monthly, as its WordPress.org plugin page explains. WP-Optimize comes from TeamUpdraft, the team behind UpdraftPlus, as the same page notes. A monthly schedule suits most sites: it clears revisions, spam and transients before they grow large, without adding much work.

Tie the cleanup to your update routine. Each time WordPress, a plugin or a theme updates, check the plugin list for anything you no longer use and delete it. That habit keeps the list short and the database lean.

A cleanup is maintenance, not a one-time fix. The same clutter returns as you edit posts, install plugins and receive comments, so a regular schedule beats a rare deep clean. Set the schedule once, keep the backup routine in place, and the site stays in shape with little effort.

Frequently asked questions

Is it safe to delete all post revisions?

Yes, if you keep the posts themselves. Revisions are old copies of your posts, and deleting them does not touch the published content. Keep a few recent revisions per post in case you need to undo an edit, and cap new ones with WP_POST_REVISIONS.

Will deleting unused plugins speed up my site?

It can help, but only a little on its own. Inactive plugins still take up disk space and can hold security flaws, so deleting them is good hygiene. The bigger speed gains come from clearing autoloaded options and expired transients, which load on every request.

What is the safest way to clean the database?

Back up first, then use a plugin that shows you what it will remove before it removes anything. Tools that rename tables first and keep a 30-day restore window, such as Attic, let you undo a mistake without restoring the whole backup.

Should I delete unattached media files?

Only after checking each file is truly unused. WordPress can list a file as unattached even when a page, post or theme file uses it. Sort by size, check the largest files first, and leave anything you are unsure about in place.

How do I know the cleanup worked?

Open Tools > Site Health and look for fewer warnings, especially the autoloaded options warning. Then load the home page and a few key pages, log in to the admin area, and confirm everything works as it did before.

Sources

  1. WP-Optimize WordPress.org
  2. Revisions WordPress.org
  3. Trash status WordPress Codex
  4. Attic — Safe Database Cleanup WordPress.org
  5. Backups WordPress Developer Resources

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test