要从术语列表中排除父类别,只需在使用检索术语列表后传递它们即可get_terms
示例:
<?php
$args = array(
\'orderby\' => \'name\',
);
$terms = get_terms( \'mytaxname\', $args );
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
if( 0 == $term->parent )
continue;
echo \'<a href="\' . get_category_link( $term ) . \'">\' . $term->name . \'</a><br/>\';
}
}
?>