the_terms( int $id, string $taxonomy, string $before = '', string $sep = ', ', string $after = '' )
Display the terms in a list.
Description Description
Parameters Parameters
- $id
-
(int) (Required) Post ID.
- $taxonomy
-
(string) (Required) Taxonomy name.
- $before
-
(string) (Optional) Before list.
Default value: ''
- $sep
-
(string) (Optional) Separate items using this.
Default value: ', '
- $after
-
(string) (Optional) After list.
Default value: ''
Return Return
(false|void) False on WordPress error.
Source Source
File: wp-includes/category-template.php
function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) { $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after ); if ( is_wp_error( $term_list ) ) { return false; } /** * Filters the list of terms to display. * * @since 2.9.0 * * @param string $term_list List of terms to display. * @param string $taxonomy The taxonomy name. * @param string $before String to use before the terms. * @param string $sep String to use between the terms. * @param string $after String to use after the terms. */ echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Get Categories of Current Post
Get a list of current post’s categories:
The output of the above code could be: categories: TV / Speaker / Monitor
I just wanted to add that the above piece of code will output the categories as href links.
E.g. Output of the code:
will be in the form:
categories: TV / Speaker / Monitor