要获取当前术语,可以使用get_query_var( \'term\' );
要获得当前的分类法,您可以使用get_query_var( \'taxonomy\' )
所以你可以这样做:
$term_slug = get_query_var( \'term\' );
$taxonomyName = get_query_var( \'taxonomy\' );
$current_term = get_term_by( \'slug\', $term_slug, $taxonomyName );
$termchildren = get_term_children( $current_term->term_id, $taxonomyName );
echo \'<ul>\';
foreach ($termchildren as $child) {
$term = get_term_by( \'id\', $child, $taxonomyName );
echo \'<li><a href="\' . get_term_link( $term->name, $taxonomyName ) . \'">\' . $term->name . \'</a></li>\';
}
echo \'</ul>\';