Slugs are unique unfortunately, even if they have different parents.
So maybe in category creation there is a way to force-uniqueness?
Understandably this is a hard problem. I think I’ll just modify the slug as its being written that way there is no clashes.
What is the hook for slug-writing in a custom taxonomy? Can’t seem to find it.
This ended being the solution – to avoid my custom taxonomy clashing with my other taxonomy (and the users are very likely to make clashing/like terms) I did this – simply altered the slug of the category term to have an appropriate suffix that would keep unique from other taxonomies.
function symbiostock_unique_category( $term_id, $tt_id, $taxonomy )
{
if ( $taxonomy == 'image-type' ) {
if ( isset( $_POST[ 'slug' ] ) && !empty( $_POST[ 'slug' ] ) ) {
$name = sanitize_title( $_POST[ 'slug' ] ) . '-images';
} elseif ( isset( $_POST[ 'tag-name' ] ) && !empty( $_POST[ 'tag-name' ] ) ) {
$name = sanitize_title( $_POST[ 'tag-name' ] ) . '-images';
} elseif ( isset( $_POST[ 'newimage-type' ] ) && !empty( $_POST[ 'newimage-type' ] ) ) {
$name = sanitize_title( $_POST[ 'newimage-type' ] ) . '-images';
}
wp_update_term( $term_id, $taxonomy, array(
'slug' => $name
) );
}
}
add_action( 'create_term', 'symbiostock_unique_category', 10, 3 );