Unable to delete a Category and Tag that share same slug

The problem is WordPress database schema for taxonomies. In database, two terms in 2 different taxonomies with same slug share the same row on terms table. They are differentiate with 2 rows on the terms_taxonomy table.

So if you want to delete only the category, you have to perform a custom sql on WordPress database.

I wrote a function for the pourpose:

function delete_slug_sharing_term( $slug = '', $taxonomy = 'category' ) {
  $term = get_term_by( 'slug', sanitize_title($slug), $taxonomy );
  if ( empty($term) || is_wp_error($term) ) return FALSE;
  global $wpdb;
  $q = "DELETE FROM $wpdb->term_taxonomy 
       WHERE taxonomy = %s 
       AND term_taxonomy_id = %d";
  return (bool) $wpdb->query( $wpdb->prepare( $q, $taxonomy, $term->term_taxonomy_id) );
}

Use it like so:

delete_slug_sharing_term( 'animals', 'category' );

you need to call it only once, so put somewhere (maybe on ‘admin_init’), go on your dashboard, check the category is removed, and if so, delete the function call (and the function too, if you want).