0

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.

1
  • What is the taxonomy? Can we see your code? What you want to use is $term_obj_list = get_the_terms( $post->ID, 'custom-taxonomy-here' ); Dec 23, 2020 at 2:04

2 Answers 2

0

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;
}
0
$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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.