You’re constantly adding new material to your site. Without regular maintenance, things will get messy. Content cleanup must be done regularly. If you clean up quarterly, you’ll save yourself from bigger headaches down the road.
In today’s post, I’m going to walk you through how to clean up your WordPress taxonomies using a powerful plugin called WP All Import/Export Pro. It’s a great solution for handling large volumes of content quickly and efficiently. If you’re uncomfortable with a little coding, you may want to ask for help from a developer. Always test changes on a staging site before touching your live site—platforms like WPEngine or Local make this super easy. Let’s jump in!
Why Taxonomy Cleanup Matters
Before we get into the nuts and bolts, let’s discuss why you should care about taxonomies. In WordPress, taxonomies are used to classify content. For example, the default taxonomies for posts are Categories and Tags, but you can also create custom taxonomies. Each taxonomy contains individual items called “terms.” For example, you could create a taxonomy called “Medium,” then this taxonomy would contain terms like Podcast, Video, or Article. Over time, as your site grows, your taxonomies will usually become messy or inconsistent. Messy content can harm your SEO and make content harder to find. Cleaning up your posts regularly ensures your site stays organized and user-friendly.
WP All Import: A Quick Overview
WP All Import/Export Pro is a paid WordPress plugin that makes large-scale content management simple. You can do many different tasks with these plugins, today we’ll focus on using them to clean up taxonomies. For this process, you’ll need both the Import PRO and Export PRO plugins, which are definitely worth the investment given the time they save. Once you get the hang of WP All Import/Export, it’ll become a go-to tool in your batch posts management toolkit.
The 9-Step Process to Clean Up Taxonomies
I know 9 steps might sound intimidating, but I’ve broken down the process into many steps to make each short and easy to follow. Here’s the breakdown:
Step 1: Review Your Site’s Content
Start by reviewing your site’s content. In this example, we’re focusing specifically on taxonomies. Take the time to go through everything, and involve anyone who regularly manages the content. SEO implications should also be considered here.
Step 2: Plan Your Cleanup
Write down simple, plain-language rules for how you want to clean up your taxonomies. For example: “Combine Tags A and B into a new Category A” or “Move Category X into Tag Y.” The key is to make a clear plan before making any changes.
Step 3: Inform Your Team
Make sure everyone on your team is aware of the cleanup. You’ll want to schedule a content freeze so that no one adds new posts while you’re making changes.
Step 4: Export Your Posts
Using WP All Export Pro, export the posts you want to clean up. You can filter by specific tags or categories if needed, or export all posts for simplicity. You only need to export the fields you will be updating. Also export the ID for post identification by the plugin, and the title, so you can see on each row of the export the post being referenced. You should pick to download a CSV.
Step 5: Write Cleanup Rules Using PHP
Next, you’ll convert your cleanup rules into PHP functions that WP All Import can use to update the site’s content. The video demo shows how you can use XPath to target fields in the CSV. WP Import Pro allows the use of custom PHP functions to manipulate the data in the CSV before the data is used to update the posts. If you’re not comfortable writing code, tools like ChatGPT can help create your functions. The video demonstrates how you can turn the following written rules:
- Combine the Video and Webinar categories into one Video category
- Delete the High Page Views tag
- Move the Upcoming tag to the Event category
Into the PHP functions below:
function create_categories($categories, $tags) {
// Convert categories string to array
$categoryArray = explode('|', $categories);
// Replace "Webinar" with "Video" and remove duplicates
$categoryArray = array_map(function($category) {
return ($category === 'Webinar') ? 'Video' : $category;
}, $categoryArray);
$categoryArray = array_unique($categoryArray);
// Ensure "Upcoming" is an exact match in tags
$tagArray = explode('|', $tags);
if (in_array('Upcoming', $tagArray)) {
// Add "Event" category if "Upcoming" tag is present and "Event" isn't already there
if (!in_array('Event', $categoryArray)) {
$categoryArray[] = 'Event';
}
}
// Return categories as a string separated by "|"
return implode('|', $categoryArray);
}
function create_tags($tags) {
// Convert tags string to array
$tagArray = explode('|', $tags);
// Remove only exact "High Page Views" and "Upcoming" tags
$tagArray = array_filter($tagArray, function($tag) {
return $tag !== 'High Page Views' && $tag !== 'Upcoming';
});
// Return tags as a string separated by "|"
return implode('|', $tagArray);
}
These PHP functions can be used to update each post’s category and tag using [create_categories({categories},{tags})] and [create_tags({tags})] respectively.
Step 6: Test on a Staging Site
This is crucial! Before making changes to your live site, run the import on a staging environment. Host like WPEngine and Cloudways make it easy to set up a staging environment. You can also test things using a Local environment. If you’re testing directly on production, which you shouldn’t be, make sure to back up your site first.
Step 7: Run the Import on Production
Once you’ve tested everything and it works, run the import on your live site. Save a template of the import on staging and then download the template so you can run the import on production. Make sure you save both your import template and your functions from staging since they are stored separately.
Step 8: Perform QA
After running the import, conduct a thorough QA. Check for broken links or redirects, especially for taxonomy and term archive pages. If you’ve renamed categories or tags, make sure all related content is updated to reflect those changes and that you’ve added any needed redirects. In my experience, you will have broken something, so ask what broke instead of asking whether something is broken.
Step 9: Document the Process
Finally, make sure to document everything. Detailed notes will make future cleanups easier and allow you to delegate things next time, or at least hand off the parts you don’t enjoy doing.
Demo Recap
In the accompanying video, I show each of the above steps with a live demo using Local. Be sure to follow along, and use the timestamps in the video to skip to specific steps if needed.
Conclusion
Cleaning up your WordPress taxonomies doesn’t have to be an overwhelming task. With the right tools and a solid plan in place, you can keep your site organized and running smoothly. I recommend scheduling content cleanups at least once a quarter to avoid letting things pile up.
If you found this guide helpful or have any questions, drop us a line. And let me know if there’s another topic you’d like me to cover in future posts!