日期:2017-07-16 阅读:1842
dmandwp系统 - wordpress系统和DM系统区块建站>>
https://codex.wordpress.org/Function_Reference/get_query_var
https://codex.wordpress.org/WordPress_Query_Vars -- 这个是根据url的路径来的,所以当在分类页时,只有cat有用,term没有用。
因为...?cat=2
$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>';