the_terms() WP 1.0
Display the terms in a list.
Works based on: get_the_term_list()
1 time = 0.00357s = very slow | 50000 times = 5.11s = fast | PHP 7.1.2, WP 4.7.3
Hooks from the function
Return
null/false. Void on success, false on failure.
Usage
the_terms( $post_id, $taxonomy, $before, $sep, $after );
- $post_id(int) (required)
- Post ID.
- $taxonomy(string) (required)
- Taxonomy name.
- $before(string)
- String to use before the terms.
Default: '' - $sep(string)
- String to use between the terms.
Default: ', ' - $after(string)
- String to use after the terms.
Default: ''
Changelog
Since 2.5.0 | Introduced. |
Code of the_terms() the terms WP 5.6
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 );
}Related Functions
From tag: Term (taxonomies terms)
- get_term()
- get_term_by()
- get_term_children()
- get_term_field()
- get_term_link()
- get_terms()
- get_the_term_list()
More from category: Any taxonomy
- edit_term_link()
- get_edit_term_link()
- get_taxonomies()
- get_taxonomy()
- is_taxonomy_hierarchical()
- register_taxonomy()