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

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

テンプレートタグ/the category

提供: WordPress Codex 日本語版
< テンプレートタグ
2008年3月6日 (木) 22:59時点におけるBono (トーク | 投稿記録)による版 (en:Template Tags/the_category 2008年2月26日 (火) 01:41 Klawdyo 版)

(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Description

Displays a link to the category or categories a post belongs to. This tag must be used within The Loop.

Usage

%%% <?php the_category('separator', 'parents' ); ?> %%%

Examples

Separated by Space

This usage lists categories with a space as the separator.

<p>Categories: <?php the_category(' '); ?></p>
Categories: WordPress Computers Blogging

Separated by Comma

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


Separated by Arrow

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(' &gt; '); ?></p>
Categories: WordPress > Computers > Blogging

Separated by a Bullet

Displays links to categories with a bullet (•) separating the categories.

%%%

Post Categories: <?php the_category(' &bull; '); ?>

%%%
Post Categories: WordPressComputersBlogging

Parameters

separator 
(string) Text or character to display between each category link. The default is to place the links in an unordered list.
parents 
(string) How to display links that reside in child (sub) categories. Options are:
  • 'multiple' - Display separate links to parent and child categories, exhibiting "parent/child" relationship.
  • '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.

Related

カテゴリータグ: the_category(), the_category_rss(), single_cat_title(), category_description(), wp_dropdown_categories(), wp_list_categories(), get_the_category(), get_the_category_by_ID(), get_category_by_slug(), get_the_category_list(), get_category_parents(), get_category_link(), is_category(), in_category()


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