Having a custom post type 'pubs' with custom taxonomy 'types' in which admin enter parent terms and their child terms. Using this code to get all the terms of current post type:
$object_terms = wp_get_object_terms($post->ID, 'types', array('fields' => 'all'));
if ($object_terms) {
echo '' . '' . '' ;
$res = '';
foreach ($object_terms as $term) {
$res .= $term->name . ',';
}
echo rtrim($res,' ,').'' . '';
}
this code displays both parent & child terms. Is there any way to exclude parent terms from the result? I need the code to display only child terms related to the current post.