get_tags

Sponsored Link

post_tagタクソノミーに各タームにおけるオブジェクトの配列を返します。

Sponsored Link

Retrieve an array of objects for each term in post_tag taxonomy.

get_tagsのパラメーター

$argsで指定された条件に基づいて投稿タグのリストを返します。デフォルトを上書きする$argsが含む事ができる引数のリストです:

Retrieves a list of post tags based on the criteria provided in $args. The list of arguments that $args can contain, which will overwrite the defaults:

orderby

デフォルトは、’name’です。name、count、またはnothing(term_idを使用します)することができます。

Default is ‘name’. Can be name, count, or nothing (will use term_id).

order

DefaultはASCです。DESCを使用することができます。

Default is ASC. Can use DESC.

hide_empty

デフォルトは、trueです。カウントが0であるタームの意味は、取得したタクソノミーに与えられており、空のタームを返す事はありません。

Default is true. Will not return empty terms, which means terms whose count is 0 according to the given taxonomy.

exclude

デフォルトは空の文字列です。カンマあるいはスペースで区切られたタームIDの文字列は、返される配列から除外します。’include’は空でない場合、’exclude’は無視されます。

Default is an empty string. A comma- or space-delimited string of term ids to exclude from the return array. If ‘include’ is non-empty, ‘exclude’ is ignored.

include

デフォルトは空の文字列です。カンマあるいはスペースで区切られたタームIDの文字列は、返される配列から含めます。

Default is an empty string. A comma- or space-delimited string of term ids to include in the return array.

number

返すためのタームの最大数です。デフォルトは空です。

The maximum number of terms to return. Default is empty.

offset

タームクエリーを相殺するための番号です。

The number by which to offset the terms query.

fields

デフォルトは’all’で、タームオブジェクトの配列を返します。’fields’が’ids’あるいは’names’の場合、それぞれ整数または文字列の配列を返します。

Default is ‘all’, which returns an array of term objects. If ‘fields’ is ‘ids’ or ‘names’, returns an array of integers or strings, respectively.

slug

この”slug”がこの値に一致するタームを返します。デフォルトは空の文字列です。

Returns terms whose “slug” matches this value. Default is empty string.

hierarchical

空でない子孫をもつタームを含めるかどうか(’hide_empty’がtrueに設定されている場合でも)。

Whether to include terms that have non-empty descendants (even if ‘hide_empty’ is set to true).

search

返されたタームの名前は、大文字と小文字を区別しないsearch’の値を含めます。デフォルトは空の文字列です。

Returned terms’ names will contain the value of ‘search’, case-insensitive. Default is an empty string.

name__like

返されるタームの名前は、大文字と小文字を区別しない’name__like’の値で開始します。デフォルトは空の文字列です。

Returned terms’ names will begin with the value of ‘name__like’, case-insensitive. Default is empty string.

pad_counts

trueに設定した場合は、多数の各タームの”count”オブジェクト変数に多数のタームの子の量を含みます。

If set to true will include the quantity of a term’s children in the quantity of each term’s “count” object variable.

get

デフォルトの空の文字列の代わりに ‘all’ が設定されている場合、タームが祖先に関係ないか、タームが空であるかどうかを返します。

If set to ‘all’ instead of its default empty string, returns terms regardless of ancestry or whether the terms are empty.

child_of

使用する場合、タームIDの整数を設定する必要があります。そのデフォルト値は0です。ゼロ以外の値を設定した場合、全ての返したタームは、取得したタクソノミーに従ったタームの子孫になります。従って、’child_of’が1つのタクソノミーより0を設定していた場合は、$taxonomiesに渡されます。なぜなら、複数のタクソノミーはタームの祖先を曖昧にしているからです。

When used, should be set to the integer of a term ID. Its default is 0. If set to a non-zero value, all returned terms will be descendants of that term according to the given taxonomy. Hence ‘child_of’ is set to 0 if more than one taxonomy is passed in $taxonomies, because multiple taxonomies make term ancestry ambiguous.

parent

使用する場合、タームIDを整数に設定剃る必要があります。そのデフォルト値は整数0とは異なる意味を持つ空の文字列です。整数の値を設定した場合は、返された全てのタームは、IDは取得したタクソノミーに準じた整数によって分類されたタームを直接の祖先とします。’parent’の引数は、タームXが、その祖父や曽祖父などではなく、タームXがタームYの父である場合のみ、タームYの’parent’と見なされることが’child_of’とは異なっています。

When used, should be set to the integer of a term ID. Its default is the empty string, which has a different meaning from the integer 0. If set to an integer value, all returned terms will have as an immediate ancestor the term whose ID is specified by that integer according to the given taxonomy. The ‘parent’ argument is different from ‘child_of’ in that a term X is considered a ‘parent’ of term Y only if term X is the father of term Y, not its grandfather or great-grandfather, etc.

戻り値

それぞれの以下のプロパティを持つオブジェクトを返します。

Each returned object has the following properties

term_id

(string)

name

(string)

slug

(string)

term_group

(string)

term_taxonomy_id

(string)

taxonomy

(string)

description

(string)

parent

(string)

count

(string)

各タグに特定のクラスと各1つにリンクするタグのリストを表示します:

Displays a list of tags with links to each one and a specific class for each tag:

$tags = get_tags();
$html = '<div class="post_tags">';
foreach ($tags as $tag){
	$tag_link = get_tag_link($tag->term_id);
			
	$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
	$html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html;

ソースファイル

get_tags()は、wp-includes/category.php内に位置しています。

get_tags() is located in wp-includes/category.php.

関連ファンクションタグ

Tags: the_tags(), tag_description(), single_tag_title(), wp_tag_cloud(), wp_generate_tag_cloud(), get_tags(), get_the_tags(), get_the_tag_list(), get_tag_link()

Sponsored Link