You can use get_ancestors()
to get an array of IDs of the ancestors of a term in any taxonomies, and in your case, you would use the last 2 items like the example below, where I used:
get_queried_object_id()
to get the ID of the term on the term archive page that you are currently viewingget_term_field()
to get the term’s name, but you can useget_term()
insteadget_term_link()
to get the URL of the term’s archive page
// Get the current term ID.
$cat_id = get_queried_object_id();
// Get the term's ancestors.
$parents = get_ancestors( $cat_id, 'car-brand' );
// Get the level 1 ancestor term, and display it.
$brand_cat_id = array_pop( $parents );
printf(
'brand: <a href="%s">%s</a><br />',
esc_url( get_term_link( $brand_cat_id ) ),
esc_html( get_term_field( 'name', $brand_cat_id ) )
);
// Get the level 2 ancestor term, and display it.
$series_cat_id = array_pop( $parents );
printf(
'series: <a href="%s">%s</a>',
esc_url( get_term_link( $series_cat_id ) ),
esc_html( get_term_field( 'name', $series_cat_id ) )
);