Assuming you want to show the terms of just one taxonomy at a time, then this will produce what you’re looking for:
function my_theme_get_child_terms(){
$return = '';
$current_term = get_queried_object()->term_id;
$term_info = get_term($current_term);
$sub_categories = get_term_children( $current_term, $term_info->taxonomy );
$return .= '<h2>' . $term_info->taxonomy . '</h2><ul>';
foreach ( $sub_categories as $cat ) {
$term = get_term_by( 'id', $cat, $term_info->taxonomy );
$return .= sprintf( '<li><a href="https://wordpress.stackexchange.com/questions/247649/%1$s">%2$s</a></li>',
esc_url( get_term_link( $cat, $term_info->taxonomy ) ),
esc_html( $term->name )
}
$return .= '</ul>';
return $return;
}
You need to put the above code inside a relevant template file
. E.g. taxonomy.php
or index.php
.