Get current post’s custom taxonomy name or id – WordPress
Sometimes you need to show first category/taxonomy name or id of current post (based on post id and taxonomy).
Code:
$myarray=get_the_terms( get_the_ID(), taxonomy-name' );
if(is_array($myarray)) {
foreach($myarray as $myarrays)
{
$temp = $myarrays;
}
}
$cname= $temp->name;
// $cid= $temp->term_id;
if (isset($cname)) echo $cname;
For getting information other that id/name: http://codex.wordpress.org/Function_Reference/get_the_terms
To show all category/taxonomy name of current post:
$terms_as_text = get_the_term_list( $post->ID, 'taxonomy-name', '', ', ', '' ) ; echo strip_tags($terms_as_text); // without links echo strip_tags($terms_as_text); // with links
For more customization:
http://codex.wordpress.org/Function_Reference/get_the_term_list






