Troubleshooting Critical Errors and Deletion Issues with Custom Taxonomies
Content
Users of the 'Custom Post Type UI' plugin sometimes encounter critical errors or unexpected behavior when creating, using, or deleting custom taxonomies. This guide compiles common issues and their solutions based on community reports.
Common Symptoms
- A critical error (White Screen of Death or 500 error) appears when a post has a term from a custom taxonomy assigned to it.
- Unable to delete a custom taxonomy, often with an error message like "[Taxonomy Name] has failed to be deleted."
- The WordPress block editor (Gutenberg) crashes with an "unexpected error" when editing posts of a certain type.
- JavaScript errors appear in the browser console, sometimes related to React or page builders like WPBakery.
- PHP errors, such as "Uncaught TypeError" or "Object of class WP_Error could not be converted to string," appear after deleting a taxonomy.
Why These Errors Happen
These problems are rarely due to a single cause. The most common underlying issues are:
- Slug Conflicts: Registering a taxonomy with a slug that is already reserved by WordPress (e.g., 'status', 'category', 'tag') or another plugin. This creates a conflict that can break core functionality.
- Theme or Plugin Conflicts: Your active theme or another plugin might have code that expects the taxonomy to exist. When the taxonomy is deleted, that code tries to use it and throws a fatal error.
- Data Remnants: Even after deleting a taxonomy from the CPTUI interface, terms from that taxonomy might remain in the database. If a theme or plugin tries to display these orphaned terms, it can cause errors.
- JavaScript Conflicts: The plugin's scripts can sometimes conflict with other scripts from page builders or the WordPress core, leading to editor crashes.
How to Troubleshoot and Fix These Issues
1. Check for Slug Conflicts
Before creating a new taxonomy, always consult the WordPress Codex list of reserved terms. Avoid using slugs like 'status', 'type', 'category', or 'tag'. If you have already created a taxonomy with a reserved slug, follow the steps below to delete it and then recreate it with a unique slug.
2. The Safe Way to Delete a Problematic Taxonomy
If you are unable to delete a taxonomy through the CPTUI admin menu, follow this procedure:
- Delete All Terms: First, go to your WordPress admin dashboard and navigate to Posts -> Your Taxonomy Name. Manually delete every single term within that taxonomy. This cleans up the data and prevents many "object of WP_Error" problems later.
- Use the CPTUI Tools: Go to CPT UI -> Tools. On the "Taxonomies" tab, you can export your current taxonomy settings. This provides a backup. You can also use the import function on this page to overwrite and correct settings if a direct delete fails.
- Attempt Deletion Again: Return to CPT UI -> Add/Edit Taxonomies and try to delete the taxonomy.
3. Perform a Conflict Test
If you are experiencing editor crashes or JavaScript errors, a conflict test is essential.
- Switch your theme to a default WordPress theme like Twenty Twenty-Four.
- Deactivate all plugins except for 'Custom Post Type UI'.
- Check if the problem persists. If it is resolved, reactivate your theme and plugins one-by-one, testing after each, to identify the culprit.
4. Check Your Error Logs
For critical PHP errors (like the "Uncaught TypeError: basename()" error in the sample thread), the exact cause is always in the server error logs. Contact your web hosting provider for help accessing these logs. The specific error message found there is the key to finding a solution.
5. Review Your Theme's Template Files
If you receive errors after successfully deleting a taxonomy, the issue is likely in your theme's code. The theme is probably calling a function like get_the_terms() or the_terms() for the deleted taxonomy without first checking if it exists. You or your developer will need to edit the theme's template files (e.g., single.php, archive.php) to add a conditional check before outputting taxonomy terms.
Conclusion
Most issues with creating and deleting taxonomies in 'Custom Post Type UI' stem from conflicts—either with reserved terms or other code on your site. The solutions almost always involve careful deletion of terms, systematic conflict testing, and reviewing server error logs for definitive answers. Always remember to backup your site before making significant changes.
Related Support Threads Support
-
created a taxonomy and when it has a value i get a critical error warning.https://wordpress.org/support/topic/created-a-taxonomy-and-when-it-has-a-value-i-get-a-critical-error-warning/
-
can’t delete taxonomyhttps://wordpress.org/support/topic/cant-delete-taxonomy/
-
Page crashes when taxonomy is deletedhttps://wordpress.org/support/topic/page-crashes-when-taxonomy-is-deleted/
-
Deleting Custom Taxonmy Errorhttps://wordpress.org/support/topic/deleting-custom-taxonmy-error/
-
Taxonomy “Status”https://wordpress.org/support/topic/taxonomy-status/
-
Deleting Taxonomies Issuehttps://wordpress.org/support/topic/deleting-taxonomies-issue/
-
No dashboard contenthttps://wordpress.org/support/topic/no-dashboard-content/
-
Norton says….https://wordpress.org/support/topic/norton-says/
-
Custom post not working as expectedhttps://wordpress.org/support/topic/custom-post-not-working-as-expected/