WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

What function will display custom taxonomies associated with a post as text?

I'm currently using get_the_term_list which works great for a singular page but not so much when using a taxonomy in the archive-postype.php permalink title tag.

share|improve this question
up vote 12 down vote accepted

wp_get_object_terms() returns the terms associated with an object (eg a post or a page or custom post) as text (normally in an array).

From the Codex page for wp_get_object_terms()

$productcategories = wp_get_object_terms($post->ID, 'productcategories');

share|improve this answer

However @anu is right, I figured out you can call the php function strip_tags to strip out the tags of the return value.

$terms = get_the_term_list( $post->ID, 'tags' );
$terms = strip_tags( $terms );
share|improve this answer

I think the best way is to implement a filter for the term list, that extract via regexp only the text, from the list

get_the_terms_list() is implemented here: http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/category-template.php#L948.

 $term_links = apply_filters( "term_links-$taxonomy", $term_links );

You can implement you own filter.

share|improve this answer

I need the same and tried Zack solution that works great. For instance, if you need onlye the term to put in css id or class. Only one anotation about the solution, the function is bad called, properly is "get_the_term_list".

I show my example:

$terms = get_the_term_list( $post->ID, 'your_taxonomy_name' );
$terms = strip_tags( $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.