- サイトデザイン工事中です。ご意見をお寄せください。
- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/get the term list
提供:WordPress Codex 日本語版
< 関数リファレンス
目次 |
説明
投稿と指定した分類に関連付けられた分類キーワードの HTML 文字列を返します。分類キーワードは、それぞれの分類キーワード一覧ページにリンクします。
使い方
<?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?>
パラメータ
- $id
- (int) (必須) Post ID
- 初期値: 0
- $taxonomy
- (string) (必須) 分類名
- 初期値: なし
- $before
- (string) (オプション) 前の文字列
- 初期値: なし
- $sep
- (string) (オプション) 区切り文字列
- 初期値: なし
- $after
- (string) (オプション) 後の文字列
- 初期値: なし
戻り値
- (文字列)
- 分類キーワードの HTML 文字列。
用例
基本的な例
ループ内で使用すると、この関数は、特定の投稿の people 分類のキーワードを出力します。
<?php echo get_the_term_list( $post->ID, 'people', 'People: ', ', ', '' ); ?>
以下のような出力になります。
People: <a href="person1">Person 1</a>, <a href="person2">Person 2</a>, ...
変更履歴
- Since: 2.5.0
ソースファイル
get_the_term_list() is located in wp-includes/category-template.php.
関連
get_the_terms(), wp_get_object_terms()
最新英語版: WordPress Codex » Function Reference/get the term list (最新版との差分)