- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/the terms
提供: WordPress Codex 日本語版
< 関数リファレンス
ある投稿に付けられたタームを文字列として表示します。
使い方
<?php the_terms( $id, $taxonomy, $before, $sep, $after ); ?>
パラメータ
- $id
- (整数) (必須) 投稿 ID
- 初期値: 0
- $taxonomy
- (文字列) (必須) タクソノミーの名前。
- 初期値: 空の文字列
- $before
- (文字列) (オプション) 先頭のタームの前に表示する文字列。
- 初期値: 空文字列
- $sep
- (文字列) (オプション) ターム(およびリンク)を区切る文字列。
- 初期値: ', '
- $after
- (文字列) (オプション) 最後のタームに続けて表示する文字列。
- 初期値: 空文字列
戻り値
- (false)
- 失敗すると false を返します。それ以外の場合、ユーザー定義の文字で区切ったカスタム分類のタームにリンクを付けて表示し、戻り値はありません。
例
現在の投稿のカテゴリーを表示
現在の投稿のカテゴリーをリスト表示します:
<?php the_terms( $post->ID, 'category', 'カテゴリー: ', ' / ' ); ?>
上記のコードの出力は例えば次のようになります: カテゴリー: テレビ / スピーカー / モニター
参考
- get_the_term_list() を使ってタームのリストを取得します。
- apply_filters() を使って、フィルター 'the_terms' を呼び出します。パラメータはタームのリスト、$taxonomy、$before、$sep そして $after です。
変更履歴
2.5.0 にて導入されました。
ソースファイル
the_terms() は wp-includes/category-template.php
にあります。
関連項目
タームタグ: is_term(), term_exists(), get_objects_in_term(), get_term(), get_term_by(), get_term_children(), get_term_link(), get_terms(), get_the_terms(), get_the_term_list(), has_term(), sanitize_term(), the_terms(), get_object_taxonomies() is_object_in_taxonomy() the_taxonomies() wp_get_object_terms(), wp_set_object_terms(), wp_get_post_terms(), wp_set_post_terms(), wp_delete_object_term_relationships()
関数リファレンス、テンプレートタグ目次もご覧ください。
最新英語版: WordPress Codex » Function Reference/the_terms (最新版との差分)