WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/the terms

Description

Displays a string of linked terms for a post.

Usage

 <?php the_terms$id$taxonomy$before$sep$after ); ?> 

Parameters

$id
(integer) (required) Post ID.
Default: None
$taxonomy
(string) (required) Taxonomy name.
Default: None
$before
(string) (optional) Text to display before the actual tags are displayed.
Default: Empty string
$sep
(string) (optional) Text or character to display between each tag link.
Default: ', '
$after
(string) (optional) Text to display after the last tag.
Default: Empty string

Return Values

(false) 
Will return false on failure. Otherwise, it displays the linked terms of a custom taxonomies separated by user defined characters, and will not return a value.

Examples

Get Categories of Current Post

Get a list of current post's categories:

<?php the_terms( $post->ID, 'category', 'categories: ', ' / ' ); ?>

The output of above code will be: categories: TV / Speaker / Monitor

Notes

Change Log

Since: 2.5.0

Source File

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

Related

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