How to find taxonomy name using only taxonomy TERM ID (or taxonomy term name)

How about using the get_term function? If you look at the code the sql it uses is as follows:

$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term) );

which should be exactly what you need!

Leave a Comment