<?php echo get_the_term_list( $post->ID, 'people', 'People: ', ' ', '' ); ?> 

returns something like this:

People: <a href="person1">Person1</a>, <a href="person2">Person2</a>, ...

How can I make it return the same thing without links like this:

People: Person1, Person2
link|improve this question

feedback

2 Answers

up vote 5 down vote accepted

It may be easier to just write the list manually, something like:

<?php
$terms = wp_get_post_tags( $post->ID );

foreach( $terms as $term )
    $term_names[] = $term->name;

echo implode( ', ', $term_names );
link|improve this answer
How would this work for a custom taxonomy? I tried: $terms = get_the_term_list( $post->ID,'people'); but that gave me an error – Carson Apr 19 '11 at 5:22
@Carson you are using the wrong function there, you want wp_get_object_terms() so it would be: $terms = wp_get_object_terms( $post->ID, 'people' ); – Joe Hoyle May 30 '11 at 23:23
Thanks, that's it! – Carson Jun 4 '11 at 0:38
feedback

I found another method that more directly answers my question:

<?php $terms_as_text = get_the_term_list( $post->ID,'people', 'People: ', ', ');
if (!empty($terms_as_text)) echo '<p>', strip_tags($terms_as_text) ,'</p>'; ?>

Credit: CSS Tricks

link|improve this answer
don't do that. use Joe's solution, but with wp_get_post_terms($post->ID, 'people') instead of wp_get_post_tags() – One Trick Pony Apr 19 '11 at 6:04
feedback

Your Answer

 
or
required, but never shown

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