Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This code:

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

Gives:

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

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

Tag

Thanks!

share|improve this question

2 Answers 2

up vote 8 down vote accepted

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.

share|improve this answer
    
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
3  
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') )
share|improve this answer
1  
What about it? Does it work? What does it do? Is this an answer and how does it help? –  kaiser Oct 17 at 10:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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