WordPress at Your Fingertips

the_terms() WP 1.0

Display the terms in a list.

1 time — 0.00357 sec (very slow) | 50000 times — 5.11 sec (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() WP 5.8.1

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 );
}

Term (taxonomies terms)

Any taxonomy

Taxonomies (category, tag)

No comments
    Log In