在列表中显示术语。
原型
the_terms( int $id, string $taxonomy, string $before = '', string $sep = ', ', string $after = '' )
参数
$id
(int)
(Required)
帖子ID。
$taxonomy
(string)
(Required)
分类名称。
$before
(string)
(Optional)
在列表之前。
$sep
(string)
(Optional)
使用此单独的项目。
$after
(string)
(Optional)
列表后。
返回值
(false|void)
WordPress错误时出错。
源文件
路径:wp-includes/category-template.php
<?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 );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/the_terms/