WordPress:Template Tags/get category parents
描述[ ]
返回类别的母类别的一个列表,包括根据ID分类的类别。
用法[ ]
%%% <?php echo(get_category_parents(category, display link, separator, nice name)); ?> %%%
例子[ ]
返回当前类别的母类别,链接是由'»'分开的 <?php echo(get_category_parents($cat, TRUE, ' » ')); ?> 会产生:
因特网 » 写博客» WordPress »
参数[ ]
- category
- (integer) 要返回母类别的类别ID的数字。如果没有设置这个ID数的话,默认为当前类别ID。
- display link
- (boolean) 创建一个链接,连接到显示的每个类别。
- separator
- (string) 将各个类别分开的符号。
- nice name
- (boolean) 返回好听的类别名称或者不返回(默认是错误的)。
相关的[ ]
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>
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>
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(' > '); ?></p>
<p>Categories: <?php the_category(' > '); ?></p>
Separated by a Bullet[ ]
用Bullet分开[ ]
Displays links to categories with a bullet (•) separating the categories.
使用bullet (•)分开类别,显示类别链接
%%%
Post Categories: <?php the_category(' • '); ?>
%%% %%%
文章类别: <?php the_category(' • '); ?>
%%%
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:
- parents
- (string)怎样显示子类别中的链接。选项有:
- 'multiple' - Display separate links to parent and child categories, exhibiting "parent/child" relationship.
- 'multiple' -分开显示母类别和子类别的链接,显示为"母/子"关系。
- 'single' - Display link to child category only, with link text exhibiting "parent/child" relationship.
- 'single' -只显示子类别链接,链接文本显示为"母/子"关系。
- 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,