WordPress:Template Tags/wp list cats

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

模板:Deprecated

Description


This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists.


描述

Displays a list of Categories as links. When one of those links is clicked, all the posts in that Category will display in the appropriate Category Template dictated by the Template Hierarchy rules. This works in much the same way as list_cats(), the difference being that arguments are given in query string format.

显示类别的一个列表,作为一列链接。当点击任何链接的时候,属于那个类别中的所有文章会在适当的类别模板中显示,类别模板是由模板层级规则规定的。这与列表_cats()的运行方式基本相似,不同的是,论证是以查询命令行的形式出现。

Replace With

取代

wp_list_categories().

wp_列表_类别()

Usage

用法

%%% <?php wp_list_cats('arguments'); ?> %%%

%%% <?php wp_list_cats('arguments'); ?> %%%

Examples

例子

Default Usage

默认用法

By default, the tag:

默认情况下,标签:

  • optionall - Does not display a link to all Categories
  • optionall –不显示连接到所有类别的链接
  • all - Text to display for link to all Categories
  • 所有的 –文本显示链接,连接到所有的类别
  • sort_column - Sorts by Category ID
  • sort_column –根据类别ID分类
  • sort_order - Sorts in ascending order
  • 分类_顺序 –以升序分类
  • file - Displays the Categories using the index.php template
  • 文件 –使用index.php模板显示类别
  • list - Sets the Categories in an unordered list (<ul><li>)
  • 列表 –在一个无序的列表上设置类别(<ul><li>)
  • optioncount - Does not display the count of posts within each Category
  • optioncount –在每个类别内部,不显示文章的数目
  • hide_empty - Does not display links to Categories which have no posts
  • 隐藏_空的 –不显示链接到没有文章的类别的链接
  • use_desc_for_title - Uses the Category description as the link title
  • 为_标题_使用_desc –将类别描述用作链接标题
  • children - Shows the children (sub-Categories) of every Category listed
  • –显示所列的每个类别的子(子类别)
  • hierarchical - Displays the children Categories in a hierarchical order under its Category parent
  • 层级的 –在母类别下,以层级的顺序,显示子类别
<?php wp_list_cats(); ?>
<?php wp_list_cats(); ?>

Categories With Excludes

Categories With Excludes

Displays Category links sorted by name, shows # of posts for each Category, and excludes Category IDs 10 and 15 from the list.

显示根据名称分类的类别链接,显示每个类别的#文章,并且从列表中删除ID为10和15的类别。

<ul>
<?php wp_list_cats('sort_column=name&optioncount=1&exclude=10, 15'); ?>
</ul>

<ul>

<?php wp_list_cats('sort_column=name&optioncount=1&exclude=10, 15'); ?>
</ul>

Show Children Only of Category

只显示类别的子类别

Displays Category links sorted by ID (sort_column=id), without showing the number of posts per Category (optioncount=0), showing only the sub-Categories titles (use_desc_for_title=0), for just the children of Category ID 8 (child_of=8).

显示根据ID分类的类别链接(sort_column=id),不显示每个类别中的文章数目(optioncount=0),只为类别ID8的子类别(child_of=8),显示子类别标题(use_desc_for_title=0)。

<?php wp_list_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=8'); ?>
<?php wp_列表_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=8'); ?>

Note: If there are no posts in a parent Category, that parent Category will not display.

注:如果母类别中没有文章,就不显示这个母类别。

Display Categories With RSS Feed Links

用 RSS Feed链接显示类别

Displays Category links sorted by name, without showing the number of posts per Category, and displays links to the RSS feed for each Category.

显示根据名称分类的类别链接,不显示每个类别中文章的数目,为每个类别显示链接,连接到RSS feed。

<?php wp_list_cats('sort_column=name&optioncount=0&feed=RSS'); ?>
<?php wp_list_cats('sort_column=name&optioncount=0&feed=RSS'); ?>

Notes on use

使用注意事项

When the 'list' parameter is set for an unordered list, the wp_list_cats() tag requires an opening and closing UL tag, but will automatically list each item as an LI.

当为一个无序的列表设置'列表'参数的时候,wp_list_cats()标签需要一个开启的和关闭的UL标签,但是会自动地将每个内容列成为一个LI

Parameters

参数

optionall
(boolean) Sets whether to display a link to all Categories. Note: This feature no longer works in WordPress 1.5.x and 2.0 but is slated to be added back at Version 2.1. Valid values:
optionall
(boolean)设置是否显示一个链接连接到所有的类别。注:WordPress 1.5x和2.0中,不再运行这个功能,但是2.1版本中由重新添加了这个功能。有效的参数值:
  • 1 (True)
  • 0 (False - default)
  • 1 (正确的)
  • 0 (错误的 – 默认)
all
(string) If optionall is set to 1 (TRUE), this defines the text to be displayed for the link to all Categories. Note: This feature no longer works in WordPress 1.5.x and 2.0 but is slated to be added back at Version 2.1. Defaults to 'All'.
all
(string)如果optionall设置为1(正确的),这定义了文本,显示链接连接到所有的类别。注:WordPress1.5x和2.0版本中不再运行这个功能,但是在2.1版本中又重新添加了这个功能。默认'所有的'
sort_column
(string) Key to sort options by. Valid values:
sort_column
(string)给选项分类的关键词。有效的参数值:
  • ID (Default)
  • ID (默认的)
  • name
  • 名称
sort_order
(string) Sort order for options. Valid values:
分类_顺序
(string)选项的分类顺序。有效的参数值:
  • asc (Default)
  • asc (默认的)
  • desc
  • desc
file
(string) The php file a Category link is to be displayed on. Defaults to index.php.
文件
(string)显示类别链接的php文件。默认为index.php
list
(boolean) Sets whether the Categories are enclosed in an unordered list (<ul><li>). Valid values:
列表
(boolean)设置是否将类别包含在一个无序的列表中(<ul><li>)。有效的参数值:
  • 1 (True - default)
  • 0 (False)
  • 1 (正确的 – 默认的)
  • 0 (错误的)
optiondates
(string) Sets whether to display the date of the last post in each Category. Valid values:
optiondates
(string)设置是否显示每个类别中的最后一篇文章的发表日期。有效的参数值:
  • 1 (True, displays Y-m-d)
  • 0 (False - default)
  • 1 (正确的, 显示 Y-m-d)
  • 0 (错误的 – 默认的)
optioncount
(boolean) Sets whether to display a count of posts in each Category. Valid values:
optioncount
(boolean)设置是否显示每个类别中的文章的数目。有效的参数值:
  • 1 (True)
  • 0 (False - default)
  • 1 (正确的)
  • 0 (错误的 – 默认的)
hide_empty
(boolean) Sets whether to hide (not display) Categories with no posts. Valid values:
隐藏_空的
(boolean)设置是否隐藏(不显示)不包含文章的类别。有效的参数值:
  • 1 (True - default)
  • 0 (False)
  • 1 (正确的 – 默认的)
  • 0 (错误的)
use_desc_for_title
(boolean) Sets whether the Category description is displayed as link title (i.e. <a title="Category Description" href="...). Valid values:
为_标题_使用_desc
(boolean)设置是否将类别描述显示为链接标题(i.e. <a title="类别 描述" href="...)。有效的参数值:
  • 1 (True - default)
  • 0 (False)
  • 1 (正确的 – 默认的)
  • 0 (错误的)
children
(boolean) Sets whether to show children (sub) Categories. Valid values:
(boolean)设置是否显示子(子) 类别。有效的参数值:
  • 1 (True - default)
  • 0 (False)
  • 1 (正确的 – 默认的)
  • 0 (错误的)
child_of
(integer) Display only the Categories that are children of this Category (ID number). There is no default. If this parameter is used, hide_empty gets set to False.
child_of
(整数)只显示类别(ID数字)的子类别。没有默认设置。如果使用参数,隐藏_空的设置为错误的。
feed
(string) Text to display for the link to each Category's RSS2 feed. Default is no text, and no feed displayed.
feed
(string)文本显示链接连接到每个类别的RSS2 feed。默认是没有文本,不显示feed。
feed_image
(string) Path/filename for a graphic to act as a link to each Categories' RSS2 feed. Overrides the feed parameter.
feed_图像
(string)一个图形的路径/文件名,作为连接到每个类别的RSS2 feed的链接。取消'feed参数。
exclude
(string) Sets the Categories to be excluded. This must be in the form of an array (ex: 1, 2, 3).
排除
(string)设置需要被排除的类别。必须是以一个数组的形式出现(ex: 1, 2, 3)。
hierarchical
(boolean) Sets whether to display child (sub) Categories in a hierarchical (after parent) list. Valid values:
层级的
(boolean)设置是否在一个层级列表(在母类别之后)中显示子类别。有效的参数值:
  • 1 (True - default)
  • 0 (False)
Note: The hierarchical parameter is not available in versions of WordPress prior to 1.5
  • 1 (正确的 – 默认的)
  • 0 (错误的)
注: 在WordPress1.5版本之前的版本中没有层级参数

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,

模板:Query String 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 函数标签页底文字

模板:查询字符串标签页底文字