Hello I have create a custom taxonomy for a custom post. I want to get the taxonomy term that is used in the current post. How to get it.
2 Answers
You can use below code to get the taxonomy by post ID:
$yourterms = get_the_terms( $post->ID , array( 'taxonomy_name') );
foreach ( $yourterms as $term ) {
echo $term->name;
}
$tags = wp_get_post_tags($post->ID);
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a> "; //this will get the taxmont term.
}
$html .= '</div>';
echo $html;
This will Help You
$term_obj_list = get_the_terms( $post->ID, 'custom-taxonomy-here' );