WordPress:Template Tags/the category

来自站长百科
Fludlen讨论 | 贡献2008年6月28日 (六) 17:05的版本
跳转至: 导航、​ 搜索

Description

描述

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

显示一个链接,连接到一个类别或者一篇文章所属的类别。必须在The Loop内部使用这个标签。

Usage

用法

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

%%% <?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>
<p>Categories: <?php the_category(' '); ?></p>
Categories: [[WordPress:#Examples|WordPress]] [[WordPress:#Examples|Computers]] [[WordPress:#Examples|Blogging]]
类别: [[WordPress:#Examples|WordPress]] [[WordPress:#Examples|电脑]] [[WordPress:#Examples|写博客]]

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>

<p>This post is in: <?php the_category(', '); ?></p>

This post is in: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|Computers]], [[WordPress:#Examples|Blogging]]


这篇文章在: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|电脑]], [[WordPress:#Examples|写博客]]


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.)

显示链接,连接到类别,用一个箭头(>)分开类别。(注: 使用箭头的时候,应该注意,因为一些读者可能以为后面加上一个&gt的类别; 是前面类别的一个子类别。)

<p>Categories: <?php the_category(' &gt; '); ?></p>

<p>Categories: <?php the_类别(' &gt; '); ?></p>

Categories: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|Computers]] > [[WordPress:#Examples|Blogging]]
Categories: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|电脑]] > [[WordPress:#Examples|写博客]]

Separated by a Bullet

有一个Bullet分开

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

显示链接,连接到类别,用一个bullet (•)将类别分开。

%%%

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

%%% %%%

文章 类被: <?php the_类别(' &bull; '); ?>

%%%

Post Categories: [[WordPress:#Examples|WordPress]] • [[WordPress:#Examples|Computers]] • [[WordPress:#Examples|Blogging]]
Post Categories: [[WordPress:#Examples|WordPress]] • [[WordPress:#Examples|电脑]] • [[WordPress:#Examples|写博客]]

Parameters

参数

separator
(string) Text or character to display between each category link. The default is to place the links in an unordered list.
分开符
(string)每个类别链接之间显示的文本或者字符。默认是将链接放入一个无序的列表中。
parents
(string) How to display links that reside in child (sub) categories. Options are:

;母:(string)怎样显示子(子)类别中的链接。选项有:

  • '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, in_category, get_category_parents, get_the_category get_category_link,

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category, get_category_parents, get_the_category get_category_link

模板:PHP Function Tag Footer 模板:PHP 函数标签 页底文字