Inside a Post / Custom Post type loop, I am trying to get child terms selected on the edit screen of that post/custom post.
For Example:
Zoologist ( Parent )
- Pre Zoologist
- Post Zoologist
Now if for any specific post / custom post if users selected all of above taxonomies including Zoologist (Parent), Pre Zoologist, Post Zoologist.
Using get_the_terms function i only want to get child taxomony, in this case Pre Zoologist, Post Zoologist.
I tried this code but it is not working:
$terms = get_the_terms( get_the_ID(), 'custom_taxonomy' );
foreach ( $terms as $term ){
if ( $term->parent == 0 ) {
echo '<div class="parent '.$term->slug.'">' . $term->name . '</div>';
}
}
Please let me know where am I making a mistake.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745309013a4621886.html
评论列表(0条)