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!
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityThis 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!
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.
echo strip_tags( get_the_term_list($post->ID, 'type') )
?
– TheDeadMedic
Dec 9 '10 at 18:00
At a super-duper simple scale, what about just:
echo strip_tags( get_the_term_list($post->ID, 'type') )