Codex

Function Reference/get the term list

Contents

Description

Returns an HTML string of taxonomy terms associated with a post and given taxonomy. Terms are linked to their respective term listing pages.

Usage

 <?php get_the_term_list$id$taxonomy$before$sep$after ?> 

Parameters

$id
(int) (required) Post ID
Default: 0
$taxonomy
(string) (required) Name of taxonomy
Default: None
$before
(string) (optional) Leading text
Default: None
$sep
(string) (optional) String to separate tags
Default: None
$after
(string) (optional) Trailing text
Default: None

Returns

(string) 
HTML string of taxonomy terms.

Example

A Basic Example

Used inside the loop this outputs the terms from the people taxonomy for a specific post.

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

This would return something like.

People: 
<a href="person1">Person 1</a>, 
<a href="person2">Person 2</a>, ...

Change Log

Source File

get_the_term_list() is located in wp-includes/category-template.php.

Related

get_the_terms(), wp_get_object_terms() get_terms()

See also index of Function Reference and index of Template Tags.