Display current taxonomy term when inside custom post type

Well, this should be pretty simple, however I couldn’t find answer anywhere on the web. all answers I found were close but no exactly what I needed.
what I need is to display just the current term of a custom post type I am in.
not all the terms just one! (the relevant one)

this is what I’m using but it displays ALL the terms which is not good for me:

Read More
<?php
$taxonomy = 'genre';
$queried_term = get_query_var($taxonomy);
$terms = get_terms($taxonomy, 'slug='.$queried_term);
if ($terms) {
  foreach($terms as $term) {
    echo $term->name;
  }
}
?>

remember – I would like to display it in my single post type template
can anyone suggest?
thanks

Related posts

Leave a Reply

4 comments

  1. Ok, so I finally found what I needed here:
    How to get current term in my custom taxonomy in WordPress?

    the last update at the bottom courtesy of @user3208:

    <?php   // Get terms for post
     $terms = get_the_terms( $post->ID , 'oil' );
     // Loop over each item since it's an array
     if ( $terms != null ){
     foreach( $terms as $term ) {
     // Print the name method from $term which is an OBJECT
     print $term->slug ;
     // Get rid of the other data stored in the object, since it's not needed
     unset($term);
    } } ?>
    

    That solved my issue!
    Thanks

  2. Taking what user3208 coded, I have added a bit of code that adds the URL to the Term. Hope that helps someone out.

    <?php   // Get terms for post
    $terms = get_the_terms( $post->ID , 'oil' );
    // Loop over each item since it's an array
    if ( $terms != null ){
    foreach( $terms as $term ) {
    $term_link = get_term_link( $term, 'oil' );
     // Print the name and URL
    echo '<a href="' . $term_link . '">' . $term->name . '</a>';
    // Get rid of the other data stored in the object, since it's not needed
    unset($term); } } ?>