WordPress at a glance

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 function:
Return

false/null. False on WordPress error.

Usage

the_terms( $id, $taxonomy, $before, $sep, $after );
$id(int) (required)
Post ID.
$taxonomy(string) (required)
Taxonomy name.
$before(string)
Before list.
Default: ''
$sep(string)
Separate items using this.
Default: ', '
$after(string)
After list.
Default: ''

Code of the_terms: wp-includes/category-template.php VER 4.9.8

<?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 array  $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)

More from category: Any taxonomy

More from Template Tags: Taxonomies (category, tag)

No comments
    Hello, !     Log In . Register