<!-- Display Categories Assigned to a post -->
<?php $taxonomy = 'category';
// Get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// Separator between links.
$separator=",";
if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) {
$gterms = wp_list_categories( array(
'title_li' => '',
'style' => 'none',
'echo' => false,
'taxonomy' => $taxonomy,
'include' => $term_ids,
'child_of' => 193
) );
$gterms = rtrim( trim( str_replace( '<br />', $separator, $gterms ) ), $separator );
}
put your parent cat id, for example, I have genre parent category, it has a lot of children, to display the children that are related to the current post you’re in put the id of the parent which is genre.
to output it plz use <?php echo $gterms; ?>