• Resolved dlikelith

    (@dlikelith)


    Hello,

    Could you please help me with php code to display custom taxonomy values.
    I mean like there is a custom taxonomy by name “localstore”, values are BLUE and RED. Is there a php code that display these values. I tried this code, it shows but with errors. I use it in woocommerce product description.

    <?php
    
    $terms = get_the_terms( $post->ID, 'localstore' );
    if ($terms) {
        foreach($terms as $term) {
          echo $term->name;
        } 
    }
    
    ?>

    Thank you.

    • This topic was modified 9 years ago by dlikelith.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    What errors are you seeing? Nothing is standing out as wrong with this code snippet.

    Would you place this code into archive.php?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @dkirmis this would go in whatever template file controls where you want to show this information.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Any changes with this one @dlikelith ?

    Thread Starter dlikelith

    (@dlikelith)

    I am not prof, so I do not know, maybe there is something with the theme, but for me this code worked:

      <?php
            
          $term_list = get_the_term_list( get_the_ID(), 'localstore', '<span class="store_post_meta_item">', ', ', '</span>' );
          if($term_list){
           echo '<a href="'.$term_list.'</a>';
         
           }  
      
    ?>
    • This reply was modified 8 years, 11 months ago by dlikelith.
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Display taxonomy values’ is closed to new replies.