How to Clean Up All the Unused Data in WordPress
Tags: wordpress
Published: 2020-12-08 04:03:06

Cleaning up unused data periodically and regularly unloads your WordPress website, thereby reducing the loading time. Therefore, this is a useful technique that all webmasters should know.

<!--more-->

There are two ways to clean up unused data: manual or plugin-using removal. I recommend that you should use both of them as I’m doing in this article.

<strong>Note:</strong>

Removing data may affect the operation of your website. Therefore, make sure that you <a href="https://gretathemes.com/backup-wordpress-site-manually-or-use-plugin/">have a backup of your WordPress site</a> before doing the next steps.
<h2>Manually Clean Up Unused Data In WordPress</h2>
<h3>Theme</h3>
You should delete unused themes to make it easier to manage and save space. To do that, go to <strong>Appearance</strong> &gt; <strong>Theme</strong>, then select the theme you want to delete, hit <strong>Theme detail</strong> &gt; <strong>Delete</strong> &gt; <strong>OK</strong>.

<img src="https://imgur.com/f4b7KHt.png" alt="Remove a theme in WordPress to Manually Clean Up Unused Data In WordPress" width="1366" height="657" />

In addition, If you want to improve the performance of your WordPress theme, refer to <a href="https://deluxeblogtips.com/improve-wordpress-theme-performance/" rel="follow">this article</a>.
<h3>Plugins</h3>
Some plugins can auto-generate data, thereby slowing down the website loading speed. So if you don't need to use a plugin anymore, let’s delete it. You can delete a plugin directly from the <strong>Admin Dashboard</strong>, but this doesn’t completely remove all the plugin’s related data. So, you can refer to <a href="https://gretathemes.com/install-wordpress-plugin/#how-to-uninstall-a-plugin">this article</a> to learn about how to completely remove a plugin's data on the WordPress website.
<h3>Post</h3>
<h4>Delete the Inappropriate Posts</h4>
You should periodically review the contents on your website and delete the duplicated, outdated ones, and the articles that have incorrect information as well.

For example, if your website has the article "Top 10 best food stores in Hanoi" but after a while they closed or relocated, you should edit or delete this article.
<h4>Delete Drafts of Revision</h4>
The <a href="https://gretathemes.com/why-you-need-revision-in-wordpress/#what-is-a-revision-in-wordpress">Revision feature</a> of WordPress helps to generate drafts to save changes in posts and restore them in case there are any problems (power failure, Internet disconnection, etc.). These drafts take up space on the website. Therefore, if you don’t need these drafts anymore, let’s delete them. The easiest way to do that is using a plugin as in part 2 of this article.

Anyway, you should reduce the amount of auto-generated drafts by limiting the number of them for a post and the time to auto-save one. To do that, add the following code to the <code>wp-config.php</code> file:
<ul>
 	<li>Code to limit the maximum number of drafts:</li>
</ul>
<pre>define (‘WP_POST_REVISIONS’, 10);</pre>
<ul>
 	<li>Code to limit the time for auto-saving drafts:</li>
</ul>
<pre>define (‘AUTOSAVE_INTERVAL’, 600);</pre>
Explanations:
<ul>
 	<li><code>10</code> is the maximum number of records to be saved.</li>
 	<li><code>300</code> is the time to automatically save the record, the unit is seconds (s)</li>
</ul>
<h3>Page</h3>
You should remove unnecessary or unsuitable pages to unload your website. Go to <strong>Pages</strong> in <strong>Admin Dashboard</strong>, choose <strong>All Pages</strong>, select the page that you want to delete then press <strong>Trash</strong>.

<img class="aligncenter" src="https://imgur.com/lodhWzD.png" alt="remove unnecessary or unused pages to unload the WordPress website." width="1366" height="657" />

If you are still confused between Post and Page, please refer to <a href="https://gretathemes.com/post-page-different/">this article</a>!
<h3>Categories and Tags</h3>
You can delete tags and categories directly from the <strong>Admin Dashboard</strong> by going to <strong>Post</strong> &gt; <strong>Tags</strong> / <strong>Categories</strong>, then select the tags or categories that you want to delete and press <strong>Delete</strong>.

<img class="aligncenter" src="https://imgur.com/aW0H0Gj.png" alt="delete unused data in tags and categories directly from the Admin Dashboard" width="1366" height="657" />
<h3>Media Library</h3>
When you upload photos and videos to the Media Library, WordPress may create several copies of multiple sizes for display in different places. These data will slow down your website, so you should delete them.

Generally, to delete these media, we go to <strong>Media</strong> &gt; <strong>Library</strong>, select images / videos and hit <strong>Delete</strong>. However, this way will take a lot of time when the number of photos and videos is too much. You can refer to some plugins for removing media faster such as WP-Optimize or Media Cleaner.

<strong>Tips</strong>: Instead of uploading media directly to your website, you should upload them on another storage platform like Youtube, Imgur, ... and embed their links in the article. Thus, your website will not have to store this data anymore.
<h2>Clean Up Unused Data in WordPress Using a Plugin</h2>
On the market, there are many data cleansing plugins that we have had a detailed review <a href="https://gretathemes.com/wordpress-cleaning-tools/">here</a>. You can choose one of them.

In this article, I use WP-Sweep - a fast, stable, powerful, and free plugin. It is one of the best plugins for cleaning up unused data. To use this plugin, let’s do as follows:

First, WP-Sweep has a free version on wordpress.org so you can <a href="https://gretathemes.com/install-wordpress-plugin/">install and activate the plugin</a> directly from the <strong>Admin Dashboard</strong>.

<img class="aligncenter" src="https://imgur.com/1XhUT5D.png" alt="Clean Up Unused Data in WordPress Using a Plugin" width="1366" height="657" />

To use the plugin, go to <strong>Tools</strong> &gt; <strong>Sweep</strong>. In the plugin interface, you have many options for cleaning and optimizing your data like the following:
<h3>Post Sweep</h3>
In this section, you’re able to clean up post-related data like:
<ul>
 	<li>Auto drafts that are created by Revision</li>
 	<li>Unused data of posts that were deleted</li>
 	<li><strong>Duplicated Post Meta</strong> (Data that is generated when you clone a post)</li>
 	<li><strong>oEmbed Caches In Post Meta</strong> (The cache is to store data about links that is embedded in posts)</li>
</ul>
If you want to delete any type of data, just hit the <strong>Sweep</strong> button. Besides, you can hit <strong>Details</strong> to see the data that you will remove. Do the same with other sections.

<img class="aligncenter" src="https://imgur.com/sfGghdk.png" alt="clean up post-related datain WordPress" width="1350" height="657" />
<h3>Comment Sweep</h3>
This section allows you to clean these data types below:
<ul>
 	<li><strong>Unapproved Comments</strong></li>
 	<li><strong>Spammed Comments</strong></li>
 	<li><strong>Deleted Comments</strong></li>
 	<li><strong>Orphaned Comment Meta</strong> (It’s the data remaining after you remove a comment)</li>
 	<li><strong>Duplicated Comment Meta</strong> (Data that is generated when cloning the comment)</li>
</ul>
<img class="aligncenter" src="https://imgur.com/y7f5eLB.png" alt="Clean up Comment Sweep in WordPress" width="1351" height="657" />
<h3>User Sweep</h3>
In this section, you’re able to clean up user data like the following:
<ul>
 	<li><strong>Orphaned User Meta</strong></li>
 	<li><strong>Duplicated User Meta</strong></li>
</ul>
In the below picture, my website doesn’t have any user data that needs to be cleansed so that the <strong>Sweep</strong> button changes to <strong>N/A</strong>. Otherwise, the <strong>Sweep</strong> button will appear.

<img class="aligncenter" src="https://imgur.com/9RgartU.png" alt="Clean up User Sweep data in WordPress" width="1366" height="657" />
<h3>Term Sweep</h3>
This section allows you to clean up these unused data below:
<ul>
 	<li><strong>Orphaned Term Meta</strong> (Term meta is data created for each term of taxonomy, it usually provides additional information and is not stored in WordPress terms table. When deleting a term from taxonomy, its term meta becomes “orphaned”)</li>
 	<li><strong>Duplicated Term Meta</strong></li>
 	<li><strong>Orphaned Term Relationship</strong> (whenever you add a post in a category, it will create a term relationship file. This file will be retained and called orphaned when you remove that post)</li>
 	<li><strong>Unused Terms</strong></li>
</ul>
Note that pressing <strong>Sweep</strong> in this section will delete the leftover data of the term in the post’s drafts, so please check carefully in the <strong>Detail</strong> section before deleting.

<img class="aligncenter" src="https://imgur.com/l690hcN.png" alt="clean up the unused data in Term Sweep" width="1352" height="657" />
<h3>Option Sweep / Database Sweep</h3>
In these two sections, you can clean up unused data in Transient memory and optimize the database table of the website. The plugin doesn’t mention how to do it in a detailed way so that you just need to choose to hit <strong>Sweep</strong> or not.

<img class="aligncenter" src="https://imgur.com/K66KYu4.png" alt="clean up unused data in Transient memory and optimize the database table of the website." width="1349" height="657" />

In case you want to delete all the above types of unused data, take a quick review of all of them then press <strong>Sweep All</strong>. That’s done!
<h2>Last Words</h2>
Cleaning up unused data is an effective way to speed up your website. Therefore, I recommend that you should scan and clean up unused data on your site periodically and regularly. In addition, you can also refer to other ways to speed up your website in <a href="https://gretathemes.com/series/speed-up-website/">this series</a>. Good luck, and do not forget to follow our upcoming posts to gain useful techniques about WordPress!

<hr />

The publication at <a href="https://gretathemes.com/clean-up-unused-data-wordpress/">GretaThemes</a>.