• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「テンプレートタグ/get the tags」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Template Tags/get_the_tags 2007年12月7日 (金) 18:21 NA3S 版)
 
(未翻訳テンプレ追加、体裁微調整)
1行目: 1行目:
== Description ==
+
{{NeedTrans}}
 +
 
 +
<div id="Description">
 +
== 説明 ==
 +
</div>
  
 
Returns an array of objects, one object for each tag assigned to the post. This tag must be used within [[The Loop]].
 
Returns an array of objects, one object for each tag assigned to the post. This tag must be used within [[The Loop]].
  
== Usage ==
+
<div id="Usage">
 +
== 使い方 ==
 +
</div>
  
 
This function does not display anything; you should access the objects and then echo or otherwise use the desired member variables.
 
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 [[Template_Tags/the_tags|<tt>the_tags()</tt>]], but without linking each tag to the tag view, and using spaces instead of commas):
+
The following example displays the tag name of each tag assigned to the post (this is like using [[テンプレートタグ/the_tags|<tt>the_tags()</tt>]], but without linking each tag to the tag view, and using spaces instead of commas):
  
 
<pre><?php
 
<pre><?php
18行目: 24行目:
 
?></pre>
 
?></pre>
  
== Examples ==
+
<div id="Examples">
 +
== 用例 ==
 +
</div>
  
 +
<div id="Show_tag_Images">
 
===Show tag Images===
 
===Show tag Images===
 +
</div>
  
 
This outputs tag images named after the <tt>term_id</tt> with the <tt>alt</tt> attribute set to <tt>name</tt>. You can also use any of the other member variables instead.
 
This outputs tag images named after the <tt>term_id</tt> with the <tt>alt</tt> attribute set to <tt>name</tt>. You can also use any of the other member variables instead.
34行目: 44行目:
 
?></pre>
 
?></pre>
  
 +
<div id="Show_the_First_tag_Name_Only">
 
===Show the First tag Name Only===
 
===Show the First tag Name Only===
 +
</div>
  
 
<pre><?php
 
<pre><?php
43行目: 55行目:
 
?></pre>
 
?></pre>
  
 +
<div id="Member_Variables">
 
==Member Variables==
 
==Member Variables==
 +
</div>
  
 
;term_id :the tag id
 
;term_id :the tag id
53行目: 67行目:
 
;count :number of uses of this tag, total
 
;count :number of uses of this tag, total
  
== Related ==
+
== 変更履歴 ==
 +
* [[Version 2.3|2.3]] : 新規テンプレートタグ
  
{{Tag tag Tags}}
+
<div id="Related">
 +
== 関連 ==
 +
</div>
 +
 
 +
{{Tag Tag Tags}}
  
 
{{Query String Tag Footer}}
 
{{Query String Tag Footer}}
 +
{{原文|Template Tags/get_the_tags|51733}}
 +
 +
{{DEFAULTSORT:get_the_tags}}
 +
[[Category:wp2.3]]
 +
 +
[[en:Template Tags/get_the_tags]]

2008年3月30日 (日) 11:25時点における版

このページ「テンプレートタグ/get the tags」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

Returns an array of objects, one object for each tag assigned to the post. This tag must be used within The Loop.

使い方

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 . ' '; 
}
}
?>

用例

Show tag Images

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="http://example.com/images/' . $tag->term_id . '.jpg" 
alt="' . $tag->name . '" />'; 
}
}
?>

Show the First tag Name Only

<?php
$tag = get_the_tags(); 
if ($tag) {
$tag = $tag[0]; echo $tag->name;
}
?>

Member Variables

term_id 
the tag id
name 
the tag name
slug 
a slug generated from the tag name
term_group 
the group of the tag, if any
taxonomy 
should always be 'post_tag' for this case
description 
the tag description
count 
number of uses of this tag, total

変更履歴

  • 2.3 : 新規テンプレートタグ


タグ: get_tag(), get_tag_link(), get_tags(), get_the_tag_list(), get_the_tags(), is_tag(), the_tags(), single_tag_title(), tag_description(), wp_generate_tag_cloud(), wp_tag_cloud()


テンプレートタグへのクエリ文字列型パラメータの渡し方関数リファレンステンプレートタグ目次もご覧ください。

最新英語版: WordPress Codex » Template Tags/get_the_tags最新版との差分