wp_tag_cloud – WordPress*リファレンス
WordPressバージョン2.3で利用可能です、このテンプレートタグwp_tag_cloudはいわゆる’タググラウド’におけるタグのリストを表示します。(そこでは、その特定のタグが何回ポストに割り当てられるか時までにそれぞれのタグのサイズが決定しています)。
⇒Available with WordPress Version 2.3, this template tag wp_tag_cloud displays a list of tags in what is called a ‘tag cloud’, where the size of each tag is determined by how many times that particular tag has been assigned to posts.
wp_tag_cloudのテンプレートタグ使用方法
<?php wp_tag_cloud(); ?>
例
デフォルトの使い方
<?php $defaults = array(
'smallest' => 8,
'largest' => 22,
'unit' => 'pt',
'number' => 45,
'format' => 'flat',
'orderby' => 'name',
'order' => 'ASC',
'exclude' => ,
'include' => ,
'link' => 'view',
'taxonomy' => 'post_tag',
'echo' => true
); ?>
デフォルトで、用法は目立ちます:
⇒By default, the usage shows:
- smallest – The smallest tag (lowest count) is shown at size 8
- largest – The largest tag (highest count) is shown at size 22
- unit – Describes ‘pt’ (point) as the font-size unit for the smallest and largest values
- number – Displays at most 45 tags
- format – Displays the tags in flat (separated by whitespace) style
- orderby – Order the tags by name
- order – Sort the tags in ASCENDING fashion
- exclude – Exclude no tags
- include – Include all tags
Cloud displayed under Popular Tags title
<?php if ( function_exists('wp_tag_cloud') ): ?>
<li>
<h2>Popular Tags</h2>
<ul>
<?php wp_tag_cloud('smallest=8&largest=22'); ?>
</ul>
</li>
<?php endif; ?>
Cloud limited in size and ordered by count rather than name
<?php wp_tag_cloud('smallest=8&largest=22&number=30&orderby=count'); ?>
Cloud returned as array but not displayed
可変$tagは他のPHPコードにおける使用のためのタグクラウドを含むでしょう。
⇒The variable $tag will contain the tag cloud for use in other PHP code
<?php $tag = wp_tag_cloud('format=array' ); ?>
wp_tag_cloudのパラメーター
smallest
⇒(integer) The text size of the tag with the smallest count value (units given by unit parameter).
largest
⇒(integer) The text size of the tag with the highest count value (units given by the unit parameter).
unit
⇒(string) Unit of measure as pertains to the smallest and largest values. This can be any CSS length value, e.g. pt, px, em, %; default is pt (points).
number
⇒(integer) The number of actual tags to display in the cloud. (Use ‘0′ to display all tags.)
format
⇒(string) Format of the cloud display.
- ‘flat’ (Default) tags are separated by whitespace
- ‘list’ tags are in UL with a class=’wp-tag-cloud’
- ‘array’ tags are in an array and function returns the tag cloud as an array for use in PHP Note: the array returned, rather than displayed, was instituted with Version 2.5.
orderby
⇒(string) Order of the tags. Valid values:
- ‘name’ (Default)
- ‘count’
order
⇒(string) Sort order. Valid values – Must be Uppercase:
- ‘ASC’ (Default)
- ‘DESC’
- ‘RAND’ tags are in a random order. Note: this parameter was introduced with Version 2.5.
exclude
⇒(string) Comma separated list of tags (term_id) to exclude. For example, ‘exclude=5,27′ means tags that have the term_id 5 or 27 will NOT be displayed. Defaults to exclude nothing.
include
⇒(string) Comma separated list of tags (term_id) to include. For example, ‘include=5,27′ means tags that have the term_id 5 or 27 will be the only tags displayed. Defaults to include everything.
タグアーカイブを作る方法
2.3における新しいタグ付けの特徴が使える付加である間、Tagアーカイブを表示するのにwp_tag_cloudのタグを使用することができます。 これが訪問者がタグ雲と同じようにタグ付けをされたすべてのポストを表示しながらどんな特定のタグも1ページクリックするときのそれであることを意味することを表示するでしょう。 Template_Hierarchyによると、tag.phpテンプレートが存在していないと、archives.phpテンプレートは使用されるでしょう。 あなたがカスタム設計することができるこのtag.phpテンプレートを作ることによって、あなたのTagアーカイブが見る方法で、このテンプレートは非常に簡単なナビゲーションのための先端にタグ雲を含んでいます。
⇒While the new tagging feature in 2.3 is a great addition, the wp_tag_cloud tag can be used to display a Tag Archive. What this means is that when a visitor clicks on any particular tag a page displaying the tag cloud and all posts tagged the same will be displayed. According to the Template_Hierarchy if a tag.php template does not exist then the archives.php template will be used. By making this tag.php template you can customize the way your Tag Archive will look, this template includes the tag cloud at the top for very easy navigation.
これをするために、新しいテンプレートは、あなたのテーマファイルに追加される必要があるでしょう。 これらはテンプレート、Template_Hierarchyに関係するすべてのための良いリソースです。 必要である基本的なステップはそうです。
⇒To do this a new template will need to be added to your theme files. These are good resources for everything pertaining to templates, Template_Hierarchy. Basic steps needed are
- 1. 命名されたtag.phpの下にコンテンツがある状態で、ファイルを作成します。
⇒Create file with the contents below named tag.php.
- 2. ファイルをあなたのテーマディレクトリにアップロードします。
⇒Upload file to your themes directory.
- 3.
リンクがあなたのページナビゲーションでTagアーカイブに単にありましたがっていたらこれが任意である、タグをクリックするとき、さもなければ、このテンプレートは使用されるでしょう。
⇒This is optional only if you would like to have a link in your page navigation to the Tag archive, otherwise when clicking on a tag this template will be used.
o このテンプレートを使用して、新しい印刷していないページを作成してください、そして、タイトルTagアーカイブをこのページに与えます。
⇒o Create a new blank page using this template, give this page the title Tag Archive.
さらにステップ3のelobarateに。
⇒To elobarate more on step three.
異なったページに異なったページTemplatesを使用するためにWordPressを構成することができます。 ->Writeページ管理が鏡板をはめる(またはあなたが使用しているWordPressのどのバージョンによるサイドバーで)Writeの下部は向かって、「ページテンプレート」とラベルされたドロップダウンです。 そこから、あなたは、この特定のページを表示するとき、どのTemplateが使用されるかを選択することができます。
⇒WordPress can be configured to use different Page Templates for different Pages. Toward the bottom of the Write->Write Page administration panel (or on the sidebar, depending on which version of WordPress you are using) is a drop-down labeled “Page Template”. From there you can select which Template will be used when displaying this particular Page.
<?php /*
Template Name: Tag Archive
*/ ?>
<div>
<?php get_header(); ?>
<h2>Tag Archive</h2>
<?php wp_tag_cloud(''); ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_footer(); ?>
流行に合わせて、このテンプレートに加えられていないので注意してください。あなたのテーマが使用する構造を決定する良い方法はsingle.phpテーマファイルを見ることです。
⇒Please Note that styling has not been added to this template. A good way to determine the structure that your theme uses is to view the single.php theme file.
使用例
関連テンプレートタグ
the_tags,get_the_tags,get_the_tag_list,single_tag_title,is_tag,get_tag_link,wp_tag_cloud,wp_generate_tag_cloud
関連記事







