On this page
the_terms( int $post_id, string $taxonomy, string $before = '', string $sep = ', ', string $after = '' ): void|false
Displays the terms for a post in a list.
Parameters
$post_idint Required-
Post ID.
$taxonomystring Required-
Taxonomy name.
$beforestring Optional-
String to use before the terms.
Default:
'' $sepstring Optional-
String to use between the terms.
Default:
', ' $afterstring Optional-
String to use after the terms.
Default:
''
Return
void|false Void on success, false on failure.
Source
File: wp-includes/category-template.php. View all references
function the_terms( $post_id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
$term_list = get_the_term_list( $post_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 );
}
Hooks
- apply_filters( 'the_terms',
string $term_list ,string $taxonomy ,string $before ,string $sep ,string $after ) -
Filters the list of terms to display.
Related
Uses
| Uses | Description |
|---|---|
| get_the_term_list() wp-includes/category-template.php | Retrieves a post’s terms as a list with specified format. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/the_terms