Back WordPress

Display category of a custom post

WRITTEN BY ON 12 Jun 2014
4,087 VIEWS • SHARES
0 comments

We can't use the_category to display its category for WordPress custom post. You'll need get_the_terms for this. It accepts two parameters - post ID and custom taxanomy name.

$terms = get_the_terms( $post->ID , 'custom_taxanomy_name' );

foreach ( $terms as $term ) {
   print_r($terms);
}								
Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.