Function Reference/the terms
Description
Displays the terms of a custom taxonomies.
Usage
<?php the_terms( $id, $taxonomy, $before, $sep, $after ); ?>
Parameters
- $id
- (int) Post ID.
- $taxonomy
- (string) Taxonomy name.
- $before
- (string) Text to display before the actual tags are displayed. The default is to display nothing.
- $separator
- (string) Text or character to display between each tag link. The default is a comma (,) between each tag.
- $after
- (string) Text to display after the last tag. The default is to display nothing.
Return Values
None.
Examples
Get categories of current post
get a list of current posts categories:
<?php the_terms( $post->ID, 'category', 'categories: ', ' <span style="color:#000">/</span> ', '' ); ?>
The output of above code will be: categories: TV / Speaker / Monitor
Change Log
Since: 2.5.0
Source File
the_terms() is located in wp-includes/category-template.php.