the_category – WordPress*リファレンス
ポストが属すカテゴリかカテゴリへのリンクを表示します。
Loopの中でこのタグを使用しなければなりません。
⇒Displays a link to the category or categories a post belongs to. This tag must be used within The Loop.
the_categoryのテンプレートタグ使用方法
<?php the_category('separator', 'parents' ); ?>
デフォルト用法
空白によって区切る
この用法はスペースがあるカテゴリについて分離符に記載します。
⇒This usage lists categories with a space as the separator.
<p>Categories: <?php the_category(' '); ?></p>
Categories: <a href=”#”>WordPress>/a> < href=”#”>Computers</a> <a href=”#”>Blogging</a>
コンマによって区切る
カテゴリ、コンマ(1以上であるなら)によって切り離された各カテゴリへのリンクを表示します。
⇒Displays links to categories, each category separated by a comma (if more than one).
<p>This post is in: <?php the_category(', '); ?></p>
This post is in: WordPress, Computers, Blogging
矢印によって区切る
矢印(>)があるカテゴリへのリンクを表示するカテゴリを切り離します。
(注意:これを使用するとき、注意してください、それに先行するものの副カテゴリとして>に続いて、何人かのビューアーがカテゴリを解釈するかもしれないので。)
⇒Displays links to categories with an arrow (>) separating the categories. (Note: Take care when using this, since some viewers may interpret a category following a > as a subcategory of the one preceding it.)
<p>Categories: < ?php the_category(' > '); ?></p>
Categories: WordPress > Computers > Blogging
中黒点(・)によって区切る
中黒点(・)がカテゴリを切り離しているカテゴリへのリンクを表示します。
⇒Displays links to categories with a bullet (・) separating the categories.
<p>Post Categories: <?php the_category(' ・ '); ?></p>
Post Categories: WordPress ? Computers ・ Blogging
the_categoryのパラメーター
separator
(string) それぞれのカテゴリリンクの間で見せるテキストかキャラクタ。
デフォルトはリンクを順不同のリストに置くことです。
⇒(string) Text or character to display between each category link. The default is to place the links in an unordered list.
parents
(string) どう子(サブ)カテゴリで住んでいるリンクを表示するか。
オプションは以下の通りです。
⇒(string) How to display links that reside in child (sub) categories. Options are:
- ‘multiple’–「親/子供」関係を示して、親子カテゴリへの別々のリンクを表示します。
⇒’multiple’ – Display separate links to parent and child categories, exhibiting “parent/child” relationship.
- ’single’–リンクテキストが「親/子供」関係を示している子供カテゴリだけへの表示リンク。
⇒’single’ – Display link to child category only, with link text exhibiting “parent/child” relationship.
注意: デフォルトは関係が全く示されていない子供カテゴリへのリンクです。
⇒Note: Default is a link to the child category, with no relationship exhibited.
関連テンプレートタグ
the_category, the_category_rss , single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category, get_category_parents, get_category_link, get_the_category
関連記事







