$terms = get_terms($taxonomy,array('parent' => 0));
if ($terms) {
foreach($terms as $term) {
$term_children = get_term_children($term->term_id,$taxonomy);
if ( count( get_term_children( $term->term_id, $taxonomy ) ) > 0 ) {
foreach($term_children as $term_child_id) {
$term_child = get_term_by('id',$term_child_id,$taxonomy);
echo $term_child->slug . '<br>';
echo $term_child->name . '<br>';
echo $term_child->description . '<br>';
}
}
if ( count( get_term_children( $term->term_id, $taxonomy ) ) === 0 ) {
echo 'The term has no children to display.';
}
}
}
评论区
发表新的留言
您可以留言提出您的疑问或建议。
您的留言得到回复时,会通过您填写的邮箱提醒您。