get_term_link

Sponsored Link

タクソノミーのタームアーカイブのためにパーマリンクを返すか、タームが存在しない場合WP_Error オブジェクトを返します。

Sponsored Link

Returns permalink for a taxonomy term archive, or a WP_Error object if the term does not exist.

get_term_linkのファンクションタグ使用方法

<?php get_term_link( $term, $taxonomy ); ?>

get_term_linkのパラメーター

$term

(object/int/string) (required) タームオブジェクト/タームID/タームスラッグのリンクが取得されます。
デフォルト:なし

(object/int/string) (required) The term object / term ID / term slug whose link will be retrieved.
Default: None

$taxonomy

(string) (required) タクソノミーのスラッグ。あなたが最初のパラメーターにタームオブジェクトを渡す場合は必要ありません。
デフォルト:なし

(string) (required) The taxonomy slug. NOT required if you pass the term object in the first parameter
Default: None

戻り値

URL (string)

タクソノミーのタームアーカイブへのURL

URL to taxonomy term archive.

WP_Error (object)

タームが存在しない場合のエラー。

Error if term does not exist.

$terms = get_terms('species');
echo '<ul>';
foreach ($terms as $term) {
    echo '<li><a href="'.get_term_link($term->slug, 'species').'">'.$term->name.'</a></li>';
}
echo '</ul>';

注意

  • 用途:apply_filters()は、完成したリンク上に’term_link’フィルターで呼び出します。
  • グローバルを使用: (unknown) $wp_rewrite
  • タームはobject, int, または stringを指定できるので、明示的に整数に変換されているあなたに渡す任意の番号を確認してください。(int)$myID
  • term->term_idは現在$termパラメーターの為に動作しません。詳細をしるには、このトラックのチケットを参照してください。
  • PHPはエラー結果をプリントしようとした場合、停止する場合があります(”キャッチできる致命的なエラー:クラスWP_Errorのオブジェクトは文字列に変換出来ませんでした”)。タームの存在を確認していない場合は、この関数の結果をチェックするためにis_string()を使用してください。
  • Uses: apply_filters() Calls ‘term_link’ filter on the finished link.
  • Uses global: (unknown) $wp_rewrite
  • Since the term can be an object, int, or string make sure that any numbers you pass in are explicitly converted to an integer. (int)$myID
  • term->term_id doesn’t currently work for the $term parameter. See this trac ticket for more info.
  • PHP may halt if you attempt to print an error result (“Catchable fatal error: Object of class WP_Error could not be converted to string”). Use is_string() to check the result of this function if you are not sure the term exists.

変更ログ

Since: 2.5.0

ソースファイル

get_term_link() is located in wp-includes/taxonomy.php.

関連ファンクションタグ

Categories: the_category(), the_category_rss(), single_cat_title(), category_description(), wp_dropdown_categories(), wp_list_categories(), get_the_category(), get_the_category_by_ID(), get_category_by_slug(), get_the_category_list(), get_category_parents(), get_category_link(), is_category(), in_category()

Terms: 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(), wp_get_object_terms(), wp_set_object_terms(), wp_get_post_terms(), wp_set_post_terms()

Sponsored Link