the_terms

函式
the_terms ( $post_id, $taxonomy, $before = '', $sep = ', ', $after = '' )
引數
  • (int) $post_id Post ID.
    Required:
  • (string) $taxonomy Taxonomy name.
    Required:
  • (string) $before Optional. String to use before the terms. Default empty.
    Required:
    Default: (empty)
  • (string) $sep Optional. String to use between the terms. Default ', '.
    Required:
    Default: ', '
  • (string) $after Optional. String to use after the terms. Default empty.
    Required:
    Default: (empty)
返回值
  • (void|false) Void on success, false on failure.
定義位置
相關方法
get_the_termsget_termsthe_title_rsshas_termthe_tags
引入
2.5.0
棄用
-

the_terms: 這個函式檢索並以列表的形式顯示與文章或自定義文章型別相關的術語。術語可以顯示為逗號分隔的列表,也可以顯示為由指定分隔符分隔的列表: 這個函式需要三個引數:文章或自定義文章型別的ID,術語所屬的分類法,以及用於分隔列表中的術語的分隔符。

在一個列表中顯示一個文章的術語。

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

常見問題

FAQs
檢視更多 >