This code:

<?php the_terms($post->ID, 'type') ?>


<a href="/archives/type/image" rel="tag">Tag</a>  

What do to if I want to display only "Tag" word, not link eg.




While you can specify separators and such in the_terms() arguments, it assumes that you actually want links.

You can discard unwanted HTML by using filter:

add_filter('the_terms', 'no_terms_links', 10, 2);

function no_terms_links($term_list, $taxonomy) {

    if ('type' == $taxonomy)
        return wp_filter_nohtml_kses($term_list);

    return $term_list;

Or just use deeper get_the_terms() function and iterate through its return to build your own markup.

  • I've added your code, but I'm still getting links :( – Wordpressor Dec 9 '10 at 16:00
  • 2
    Don't forget to change type to your actual taxonomy in snippet. – Rarst Dec 9 '10 at 17:29
  • 4
    At a super-duper simple scale, what about just echo strip_tags( get_the_term_list($post->ID, 'type') ) ? – TheDeadMedic Dec 9 '10 at 18:00
  • Yeaah, that would do it... I deem today - the day of overthinking code. :) – Rarst Dec 9 '10 at 18:14

At a super-duper simple scale, what about just:

echo strip_tags( get_the_term_list($post->ID, 'type') )
  • 1
    What about it? Does it work? What does it do? Is this an answer and how does it help? – kaiser Oct 17 '14 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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