Retrieves term parents with separator.
get_term_parents_list( int $term_id, string $taxonomy, string|array $args = array() )
Example:
<?php
if ( is_category() ) {
// Get the current category term id.
$query_obj = get_queried_object();
$term_id = $query_obj->term_id;
echo get_term_parents_list( $term_id, 'category' );
}
?>