Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress custom function display only child terms
function get_child_terms_function($postid=null,$taxonomy){
if ($postid === null)
return false;
$terms=wp_get_post_terms($postid,$taxonomy);
if($terms){
foreach ( $terms as $term ) {
if($term->parent!='0') $termarr[]=$term;
}
return $termarr;
}
return false;
}
$terms = get_child_terms_function( $post_id, 'your_custom_taxonomy' );
foreach ( $terms as $term ) {
echo($term->name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment