WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Trying to print my custom post type's taxonomy but without the link. Tried this, but doesn't seem to work, any suggestions?

$text = the_terms($post->ID,'type','','',''); 
echo strip_tags($text);

Any help would be greatly appreciated... I'm about to start punching babies.

share|improve this question
up vote 2 down vote accepted

You could use a filter and strip_tags(), as you suggested. Example using post tags, since that's the taxonomy I had available:

function my_remove_links( $term_links ) { 
    return array_map('strip_tags', $term_links);
add_filter('term_links-post_tag', 'my_remove_links');

Really though, I would just get_the_terms() and and craft the output yourself:

function the_simple_terms() {
    global $post;
    $terms = get_the_terms($post->ID,'post_tag','',', ','');
    $terms = array_map('_simple_cb', $terms);
    return implode(', ', $terms);

function _simple_cb($t) {
    return $t->name;

echo the_simple_terms();
share|improve this answer
you are incredible that you so much, I ended up using the second option. beautiful. – pete_schuster Oct 28 '10 at 21:24

the_terms() echos the output and returns null. So your first line is echoing the terms with the anchor tags and then your echoing null in the second line. You want to use get_the_terms().

share|improve this answer

Your Answer


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.