I have custom post "product" in WordPress admin panel to add products and also added category in that custom post.While showing that custom post on front-end how to show category of that custom post.
Here the_category() function of WordPress doesn't work because that work only for default category not for custom post category.
Here's my code to fetch category of custom post :-
< ?php
$terms = get_the_terms( $post->ID , 'taxonomyname' );
foreach ( $terms as $term ) {
echo $term->name;
}
?>