get_the_tag_list

Sponsored Link

現在の投稿に関連するタグのHTML文字列を生成させます。それぞれのタグの名前は関連’タグ’ページにリンクされるでしょう。 あなたは、すべてのタグの前後と、各タグの間に文字列を置く機能使うことができます。 ‘Loop’でこのタグを使用しなければなりません。

Sponsored Link

Generates a HTML string of the tags associated with the current post. The name of each tag will be linked to the relevant ‘tag’ page. You can tell the function to put a string before and after all the tags, and in between each tag. This tag must be used inside ‘The Loop’.

get_the_tag_listのテンプレートタグ使用方法

この機能は何も表示しません; 物にアクセスします。次に、あなたは、必要なメンバー変数を反映するべきであるか、またはそうでなければ、使用するべきです。

以下の例はポストに割り当てられたそれぞれのタグのタグ名を表示します。the_tags()を使用しますが、各タグをタグ視点にリンクして、コンマの代わりに空間は使用しないで、これはあります):

This function does not display anything; you should access the objects and then echo or otherwise use the desired member variables.

The following example displays the tag name of each tag assigned to the post (this is like using the_tags(), but without linking each tag to the tag view, and using spaces instead of commas):

<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ' '; 
}
}
?>

使用例

イメージタグを表示する方法

この出力のタグの画像をterm_idには、altと名付け名に設定する属性です。また、代わりに、他のメンバ変数を使用することができます。

This outputs tag images named after the term_id with the alt attribute set to name. You can also use any of the other member variables instead.

<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo '<img src="<a href="http://example.com/images/'" class="external free" title="http://example.com/images/'" rel="nofollow">http://example.com/images/'</a> . $tag->term_id . '.jpg" 
alt="' . $tag->name . '" />'; 
}
}
?>

最初のタグ名のみ表示する方法

<?php
$tag = get_the_tags(); 
if ($tag) {
$tag = $tag&#91;0&#93;; echo $tag->name;
}
?>

Member変数

term_id

タグIDです。

the tag id

name

タグ名です。

the tag name

slug

slugは、タグ名から生成されました。

a slug generated from the tag name

term_group

もしあれば、タググループです。

the group of the tag, if any

taxonomy

このような場合いつも’post_tag”であるべきです。

should always be ‘post_tag’ for this case

description

タグの説明です。

the tag description

count

タグの使用総数です。

number of uses of this tag, total

関連

Template:Tag tag Tags

使用例

関連テンプレートタグ

the_tags,get_the_tags,get_the_tag_list,single_tag_title,is_tag,get_tag_link,wp_tag_cloud,wp_generate_tag_cloud

Sponsored Link