- Why Clean Up a WordPress Site?
- What to do Before you start Cleaning Up your WordPress Site?
- How to Clean Up a WordPress Site: 4 Quick Methods
- Optimizing Your Database Tables After the Cleanup
- Best Practices for Keeping Your WordPress Site Clean
- Conclusion
- Frequently Asked Questions (FAQs)
- Q1. Why should you clean up your WordPress site?
- Q2. What should be done before start cleaning up the WordPress site?
- Q3. How to manually clean up my WordPress site using technical tools?
- Q4. What plugins can you use to automate the cleanup process?
- Q5. What best practices can help maintain a clean and optimized WordPress site over time?
How to Clean Up a WordPress Site

- Why Clean Up a WordPress Site?
- What to do Before you start Cleaning Up your WordPress Site?
- How to Clean Up a WordPress Site: 4 Quick Methods
- Optimizing Your Database Tables After the Cleanup
- Best Practices for Keeping Your WordPress Site Clean
- Conclusion
- Frequently Asked Questions (FAQs)
- Q1. Why should you clean up your WordPress site?
- Q2. What should be done before start cleaning up the WordPress site?
- Q3. How to manually clean up my WordPress site using technical tools?
- Q4. What plugins can you use to automate the cleanup process?
- Q5. What best practices can help maintain a clean and optimized WordPress site over time?
WordPress websites are prone to collecting unnecessary information as you continue adding new content, updating themes, installing plugins, and making any other website changes.
This collection of data over time can make your site slow, use additional server resources, and even become a security concern for your site.
Here in this blog, you will learn how to clean up a WordPress site so that it remains fast, secure, and simple to maintain.
Why Clean Up a WordPress Site?
Making your WordPress site clean and optimized is crucial for enhanced performance, security, and efficiency.
Gradually over time, your site tends to store some unnecessary data, which might harm different areas of your website. Regular cleanup helps avoid such problems and maintains a hassle-free user experience.
Here are a few of the other reasons why you might want to clean up your WordPress website.
- Slow Performance: Storage of unwanted data over time, such as old revisions, spam, unused themes, etc., slows down the loading speed of your WordPress website.
- Consumption of Resource: Excess data makes the servers use more of your site’s resources, which might result in increased expenses of hosting along with limited performance.
- Security Threats: Unused or outdated parts might open doors for cyber risks, making security threats more likely to occur on your site.
- Data Collection: Your websites gradually, over the years, store a lot of unnecessary data, such as unnecessary metadata and cached data, which makes the database full and inefficient to work.
What to do Before you start Cleaning Up your WordPress Site?
Before you start the actual process of cleaning up your site, you first must completely back up your database and all of your site’s files. This backup provides you with a means to restore your site if something goes wrong while cleaning your site.
You can take the backup with the help of plugins such as UpdraftPlus or Duplicator, your hosting control panel’s backup feature, or you can even manually export the database using phpMyAdmin, followed by downloading all the site files using an FTP client.
How to Clean Up a WordPress Site: 4 Quick Methods
You can either go for the manual cleanup or use any plugin to clean up your site. In this guide, we will walk you through both processes so that you can choose one of them at your convenience.
Method 1: Manual Cleanup using phpMyAdmin
If you don’t mind doing a little technical work, you can manually clean up your database using phpMyAdmin. Here are the steps that yu can follow to clean up your WordPress site.
1. Optimizing Database Tables
Optimizing the tables helps in removing unused space that piles up over time.
- Simply first log into your hosting control panel and access the phpMyAdmin.
- Then, choose the database that your WordPress site uses.
- Look for the tables that are regularly updated, such as posts, comments, and user meta, and tables that have become full, such as wp_options or wp_postmeta. You can also select the tables by marking the Check all box as checked below the table lists.
- Once you selected the tables, click on the With selected dropdown list to open the menu.
- Then, from the list, click on the Optimize table.
- Once the cleanup is completed, you will see a success message on your screen like this:
- In case you want to delete the entire database and not some of its selected tables, you need to navigate to the Databases tab, select the tables that you want to delete, and click on the Drop button.
2. Deleting Unused Data
Over time, your database might contain many unnecessary files, plugins, and themes.
Step 1: Unused Themes and Plugins
If you have deactivated a theme or plugin, their remaining data will still be in your site’s database.
You can write this type of code for deleting the unused themes:
DELETE FROM wp_options WHERE option_name LIKE 'template_%' OR option_name LIKE 'stylesheet_%';
For deleting the plugins, write these SQL commands:
DELETE FROM wp_options WHERE option_name = 'active_plugins';
Step 2: Unused Media Files
There are certain media files that you have not yet used any of your posts, they pile up and consume a large amount of space in your database which gradually flows down your site’s performance.
You can easily identify these media files by checking the wp_posts table for attachments with a post_parent value of 0.
To remove these unused media files, you can use these SQL commands:
DELETE FROM wp_posts WHERE post_type = 'attachment' AND post_parent = 0;
Step 3: Old Pages and Posts
If you have draft pages or posts that are no longer necessary, you can also delete them to clean up your WordPress site.
To delete the Posts, go for these SQL codes:
DELETE FROM wp_posts WHERE post_type = 'post' AND post_status = 'draft';
For the Pages, type in these commands:
DELETE FROM wp_posts WHERE post_type = 'page' AND post_status = 'draft';
Step 4: Unused Tags
Remove all the unused tags that are not required in any of your posts:
DELETE FROM wp_terms WHERE term_id IN ( SELECT term_id FROM wp_term_taxonomy WHERE count = 0 );
3. Cleaning Up Comments
Step 1: Spam Comments
Delete all the spam comments on your WordPress site by typing the following SQL command:
DELETE FROM wp_comments WHERE comment_approved = 'spam';
Step 2: Unapproved Comments
Delete all the unapproved comments from your WordPress site by typing the below SQL command:
DELETE FROM wp_comments WHERE comment_approved = 0;
You can also use the WordPress dashboard to remove spam and unapproved comments and delete them in bulk.
4. Removing Post Revisions
WordPress generally saves multiple revisions of your posts. While it helps recover the previous versions, these also become issues for your slow WordPress site.
To remove them, run this SQL query:
DELETE FROM wp_posts WHERE post_type = 'revision';
This command helps to delete all revisions that WordPress creates for all your posts and frees up the database space.
If you want to restrict WordPress from taking future revisions also, add a line to your wp-config.php file:
define( 'WP_POST_REVISIONS', 5 ); // Adjust the number to keep only the latest 5 revisions
5. Eliminating Old Shortcodes
In some cases, themes or plugins leave behind some shortcodes that are no longer used on your site.
Manually reviewing and deleting these might be very time-consuming, but for a small number of pages, you can switch to the Text or HTML editor mode in your post editor and remove these outdated shortcodes.
6. Removing Pingbacks and Trackbacks
Pingbacks and trackbacks help to notify you when any other site links to the content of your site, but they might also use up your database.
To delete them using phpMyAdmin, run this SQL command:
DELETE FROM wp_comments WHERE comment_type = 'pingback' OR comment_type = 'trackback';
You can also choose to remove them through your WordPress dashboard by filtering comments by type and then deleting them.
7. Deleting Transients
Transients are the temporary cached data that gets stored in your database. While they might be useful, gradually they also pile up in your database and slow down your site if not cleaned regularly.
Delete all transients with the following SQL command:
DELETE FROM wp_options WHERE option_name LIKE '_transient_%';
Now, if you are someone who prefers using WP-CLI, run:
wp transient delete --all
Method 2: Automating Cleanup With WordPress Plugins
In case you are not comfortable with using SQL commands or manual database management, using plugins offers a user-friendly alternative for you.
Plugins can automate most of these cleanup tasks, reduce the risk of errors, and even schedule cleanups. Here are some recommended options that you might go for.
1. WP-Optimize
WP-Optimize is a highly used plugin that assists you in cleaning and optimizing your database by deleting post revisions, spam comments, unused tags, and expired transients.
The best feature about it is the option of automatic cleanups on a scheduled basis, so you don’t have to start the process ever manually.
Pros:
- Scheduled cleanups
- Easy-to-use interface
- All-round options for cleanup and optimization
Cons:
- Some of the advanced features need the pro version
2. WP Sweep
WP Sweep is a lightweight plugin that deletes unused, orphaned, and redundant data from your database. It has an option for preview so you know what data is to be deleted before you commit the cleanup
Pros:
- Simple to use and straightforward
- Has a preview feature
- Great for specialized cleanup operations
Cons:
- It may not be adequate for extremely big databases
3. Advanced Database Cleaner
The Advanced Database Cleaner plugin also has a free and premium version that allows additional advanced cleanup actions like custom queries and timed cleanups to be performed. It is particularly best for individuals requiring more command of what can be deleted
Pros:
- Improved scheduling
- Better cleaning actions using custom queries
Cons:
- The advanced features might come at a cost
- Slightly higher learning curve
4. WP DBManager and WP Reset
Other worthy mentions are WP DBManager, which provides backup and repair capabilities as well as cleanup, and WP Reset, which is best used for those who wish to restore their site to a default state but maintain important data
Method 3: Cleaning Up Files and Code Without SQL Commands
Here are the alternative ways to remove your unused themes, plugins, and media files without using SQL commands.
1. Removing Unused Themes and Plugins
Unused themes and plugins can leave residual files and data behind. To remove them:
- From the Dashboard: Navigate to Appearance in your WordPress dashboard, followed by Themes and Plugins.
- Simply deactivate and delete any of your themes or plugins that you are no longer using.
2. Cleaning Up the Media Library
With time, the media library may become clogged with images and files that are no longer used:
- Simply navigate to the Media Library in your WordPress dashboard.
- Click on Bulk select and select the images you want to delete.
- Lastly, click on Delete Permanently.
3. Deleting Pingbacks and Trackbacks
There is an alternative for deleting pingbacks and trackbacks rather than writing SQL commands. You simply need to disable both of them from Settings and then Discussion in WordPress and deactivate the first two settings.
4. Removing Orphan Data
Orphan data consists of metadata or leftover data from deleted posts and plugins. Plugins such as WP-Optimize or WP Sweep can delete this data, which further trims bloat and accelerates your site.
Optimizing Your Database Tables After the Cleanup
Once you delete all the unused data, it is now time to optimize the tables that still exist to regain space and enhance performance. This is particularly crucial after a massive cleanup.
In this guide, we will be showing you steps to optimize tables within phpMyAdmin.
- Open phpMyAdmin: Log in to phpMyAdmin through your hosting interface.
- Choose Your Database: Select the tables that you used while cleaning up your WordPress site.
- Optimize: Once the tables are selected, choose the Optimize table option from the drop-down menu and Confirm.
- Verify Results: You will get a confirmation message that the tables have been optimized successfully.
Best Practices for Keeping Your WordPress Site Clean
Here are some best practices that you can follow to maintain your site in top condition:
1. Set Regular Cleanups
- Frequency: For high-traffic sites, weekly or bi-weekly cleanup could be best. For low-traffic sites, monthly cleanups could be enough.
- Automation: Use plugins that offer scheduled maintenance tasks. This ensures that your database and files are regularly pruned without manual intervention.
2. Monitor Your Database Size
- Regular Checks: Use plugins like WP-Optimize or Advanced Database Cleaner to monitor the storage memory of your database.
- Alerts: Set up notifications to check the storage of your database regularly. If it increases unexpectedly, it might indicate that unwanted data is piling up.
3. Keep Software Updated
- Core, Themes, and Plugins: Update WordPress core, themes, and plugins regularly to reduce security threats and enhance the performance of your WordPress site.
- Cleanup After Updates: Updates, at times, leave unused data behind. Running a quick cleanup after large updates is a good idea.
4. Use Caching and Performance Plugins
- Caching: Plugins such as WP Rocket not only cache but also contain database optimization functions. They offer a simple, one-click method to purge your database and increase page loading speed.
- Performance Monitoring: Software that monitors your site’s performance and resource consumption can warn you of problems before they become major issues.
5. Auditing Installed Plugins and Themes Regularly
- Deactivate and Delete: If you’re not using a plugin or theme, deactivate it and remove it entirely from your WordPress installation.
- Review Data: Some plugins leave behind data even after being deactivated. Occasionally check your database for orphaned data and clean it up.
Conclusion
A clean WordPress website is crucial for a speedy, secure, and trustworthy online presence. By cleaning your database and files regularly, either manually using phpMyAdmin or with the help of a certain plugin, you lower the server load, decrease the page loading time, and eliminate possible security threats.
Incorporate regular cleanups into your site’s maintenance routine. If you are new to WordPress or you are not comfortable with the SQL commands, you can go for a trusted plugin.
Keeping your website clean and optimized is not just about performance. It is also about providing a better experience for your site visitors and ensuring that your site remains secure.
Whether you are running a personal blog, an online store, or a corporate website, investing time in regular cleanups is an investment in your site’s future.
Frequently Asked Questions (FAQs)
Q1. Why should you clean up your WordPress site?
Cleaning up your site improves load times, saves server resources, and reduces security risks by removing unwanted data like old revisions and spam.
Q2. What should be done before start cleaning up the WordPress site?
Always back up your complete database and files using a plugin or manual method to ensure you can restore your site if something goes wrong.
Q3. How to manually clean up my WordPress site using technical tools?
You can use phpMyAdmin to optimize tables and delete unused data such as old revisions, spam comments, unattached media, and unnecessary shortcodes.
Q4. What plugins can you use to automate the cleanup process?
Plugins such as WP-Optimize, WP Sweep, and Advanced Database Cleaner automate cleanup tasks and offer scheduled maintenance to make your site efficient.
Q5. What best practices can help maintain a clean and optimized WordPress site over time?
Set a regular cleanup schedule, monitor database size, update your software, and audit unused themes and plugins to keep your site efficient and secure.
Sagnika Goswami
Hi, I’m Sagnika Goswami. I am a tech enthusiast with a knack for content writing. Read my blogs for your daily insights.
Leave a Reply