WordPress:Template Tags/wp list cats

来自站长百科
跳转至: 导航、​ 搜索

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.


描述[ ]

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

取代[ ]

wp_list_categories().

用法[ ]

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

例子[ ]

默认用法[ ]

默认情况下,标签:

  • optionall –不显示连接到所有类别的链接
  • all - 文本显示链接,连接到所有的类别
  • sort_column - 根据类别ID分类
  • sort_order - 以升序分类
  • file - 使用index.php模板显示类别
  • list - 在一个无序的列表上设置类别(<ul><li>)
  • optioncount -在每个类别内部,不显示文章的数目
  • hide_empty - 不显示链接到没有文章的类别的链接
  • use_desc_for_title - 将类别描述用作链接标题
  • 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[ ]

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

<ul>

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

只显示类别的子类别[ ]

显示根据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'); ?>

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

用 RSS Feed链接显示类别[ ]

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

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

使用注意事项[ ]

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

参数[ ]

optionall
(boolean)设置是否显示一个链接连接到所有的类别。注:WordPress 1.5.x和2.0中,不再运行这个功能,但是2.1版本中又重新添加了这个功能。有效的参数值:
  • 1 (True)
  • 0 (False - default)


all
(string) 如果optionall设置为1(true),这定义了文本,显示链接连接到所有的类别。注:WordPress1.5x和2.0版本中不再运行这个功能,但是在2.1版本中又重新添加了这个功能。默认'all'
sort_column
(string)给选项分类的关键词。有效的参数值:
  • ID (Default)
  • name
sort_order
(string) 选项的分类顺序。有效的参数值:
  • asc (Default)
  • desc
file
(string) 显示类别链接的php文件。默认为index.php
list
(boolean) 设置是否将类别包含在一个无序的列表中(<ul><li>)。有效的参数值:
  • 1 (True - default)
  • 0 (False)
optiondates
(string)设置是否显示每个类别中的最后一篇文章的发表日期。有效的参数值:
  • 1 (True, displays Y-m-d)
  • 0 (False - default)
optioncount
(boolean)设置是否显示每个类别中的文章的数目。有效的参数值:
  • 1 (True)
  • 0 (False - default)
hide_empty
(boolean) 设置是否隐藏(不显示)不包含文章的类别。有效的参数值:
  • 1 (True - default)
  • 0 (False)
use_desc_for_title
(boolean) 设置是否将类别描述显示为链接标题(i.e. <a title="类别 描述" href="...)。有效的参数值:
  • 1 (True - default)
  • 0 (False)
children
(boolean) 设置是否显示子(子) 类别。有效的参数值:
  • 1 (True - default)
  • 0 (False)
child_of
(integer) 只显示类别(ID数字)的子类别。没有默认设置。如果使用参数,隐藏_空的设置为错误的。
feed
(string)文本显示链接连接到每个类别的RSS2 feed。默认是没有文本,不显示feed。
feed_image
(string)一个图形的路径/文件名,作为连接到每个类别的RSS2 feed的链接。取消'feed参数。
exclude
(string)设置需要被排除的类别。必须是以一个数组的形式出现(ex: 1, 2, 3)。
hierarchical
(boolean) 设置是否在一个层级列表(在母类别之后)中显示子类别。有效的参数值:
  • 1 (True - default)
  • 0 (False)
注: 在WordPress1.5版本之前的版本中没有层级参数

相关的[ ]

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 函数标签页底文字

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