Problem with taxonoy term slugs (bug? & fix)
-
I’ve understood taxonomy term slugs are supposed to be canonical across all taxonomies. However, in the single use-case where you create a new term (tag, or category, or custom) which has exactly the same slug and name as a previously existing term in another taxonomy, the WordPress code which ensures the slug is unique is not being run.
You can try this in an instance of WordPress – create a category called ‘Test’, with a slug of ‘test’. Then create a tag called ‘Test’ with a slug of ‘test’. The usual wordpress behaviour (which you will see if you create a tag called ‘Anothertest’ with a slug of ‘test’ ) would be to create the second slug as test-2. The current WordPress release (incorrectly) creates a reference to the original slug, effectively rendering the category and the tag identical.
The change is a single line addition to wp-includes/taxonomy.php – adding:
$slug = wp_unique_term_slug($slug, (object) $args);
in wp_insert_term after the special casing for an empty slug – if ( empty($slug) ) $slug = sanitize_title($name);
Does that sound right?
-Benjamin
- The topic ‘Problem with taxonoy term slugs (bug? & fix)’ is closed to new replies.