WordPress: Template Tags/get category parents:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == Returns a list of the parents of a category, including the category, sorted by ID. == Usage == %%% <?php echo(get_category_parents(category, display link, separator, ...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述==


Returns a list of the parents of a category, including the category, sorted by ID.
Returns a list of the parents of a category, including the category, sorted by ID.
返回类别的母类别的一个列表,包括根据ID分类的类别。


== Usage ==
== Usage ==
== 用法 ==


%%% <?php echo(get_category_parents(category, display link, separator, nice name)); ?> %%%
%%% <?php echo(get_category_parents(category, display link, separator, nice name)); ?> %%%
%%% <?php echo(get_category_parents(类别, 显示链接, 分隔符, 好听的名称)); ?> %%%


== Example ==
== Example ==
== 例子 ==


Returns the parent categories of the current category with links separated by '&raquo;'
Returns the parent categories of the current category with links separated by '&raquo;'
  <?php echo(get_category_parents($cat, TRUE, ' &amp;raquo; ')); ?>
  <?php echo(get_category_parents($cat, TRUE, ' &amp;raquo; ')); ?>
will output:
will output:
返回当前类别的母类别,链接是由'&raquo;'分开的
<?php echo(get_category_parents($cat, TRUE, ' &amp;raquo; ')); ?>
会产生:


Internet &raquo; Blogging &raquo; WordPress &raquo;
Internet &raquo; Blogging &raquo; WordPress &raquo;
因特网 &raquo; 写博客&raquo; WordPress &raquo;


== Parameters ==
== Parameters ==
== 参数 ==


; category : (''integer'') The numeric category ID for which to return the parents. Defaults to current category, if one is set.  
; category : (''integer'') The numeric category ID for which to return the parents. Defaults to current category, if one is set.  
;类别 : (''整数'')要返回母类别的类别ID的数字。如果没有设置这个ID数的话,默认为当前类别ID。


; display link : (''boolean'') Creates a link to each category displayed.  
; display link : (''boolean'') Creates a link to each category displayed.  
第24行: 第43行:


; nice name : (''boolean'') Return category nice name or not (defaults to FALSE).
; nice name : (''boolean'') Return category nice name or not (defaults to FALSE).
;显示链接 : (''boolean'') 创建一个链接,连接到显示的每个类别。
; 分隔符 : (''string'') 将各个类别分开的符号。
; 好听的名称: (''boolean'') 返回好听的类别名称或者不返回(默认是错误的)。


== Related ==
== Related ==
第30行: 第55行:


{{Tag Footer}}
{{Tag Footer}}
== 相关的 ==
{{标签 类别 标签}}
{{标签 页底文字}}

2008年7月1日 (二) 16:21的版本

Description

描述

Returns a list of the parents of a category, including the category, sorted by ID.

返回类别的母类别的一个列表,包括根据ID分类的类别。

Usage

用法

%%% <?php echo(get_category_parents(category, display link, separator, nice name)); ?> %%%

%%% <?php echo(get_category_parents(类别, 显示链接, 分隔符, 好听的名称)); ?> %%%

Example

例子

Returns the parent categories of the current category with links separated by '»'

<?php echo(get_category_parents($cat, TRUE, ' &raquo; ')); ?>

will output:

返回当前类别的母类别,链接是由'»'分开的 <?php echo(get_category_parents($cat, TRUE, ' &raquo; ')); ?> 会产生:

Internet » Blogging » WordPress »

因特网 » 写博客» WordPress »

Parameters

参数

category
(integer) The numeric category ID for which to return the parents. Defaults to current category, if one is set.
类别
(整数)要返回母类别的类别ID的数字。如果没有设置这个ID数的话,默认为当前类别ID。
display link
(boolean) Creates a link to each category displayed.
separator
(string) What to separate each category by.
nice name
(boolean) Return category nice name or not (defaults to FALSE).
显示链接
(boolean) 创建一个链接,连接到显示的每个类别。
分隔符
(string) 将各个类别分开的符号。
好听的名称
(boolean) 返回好听的类别名称或者不返回(默认是错误的)。

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,

模板:Tag Footer

相关的

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]]


This post is in: [[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.)

用箭头显示类别链接(>)分开类别。(注: 使用这种方法的时候,应该注意,有的访客认为类别后面的> 是前面类别的子类别。)

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

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

Categories: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|Computers]] > [[WordPress:#Examples|Blogging]]
类别: [[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_category(' &bull; '); ?>

%%%

Post Categories: [[WordPress:#Examples|WordPress]] • [[WordPress:#Examples|Computers]] • [[WordPress:#Examples|Blogging]]
文章类别: [[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:
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,

模板:PHP Function Tag Footer


相关的

模板:标签类别标签

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