WordPress:Template Tags/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()的运行方式基本相似,不同的是,list_cats使用一个很长的论证查询字符串,然而list_cats()使用以文本为基础的查询论证。WordPress 2.1拥有一个新的而且更具有包含性的模板标签 wp_list_categories,试图取代 wp_list_cats and list_cats

取代[ ]

wp_list_categories().


用法[ ]

%%% <?php list_cats(optionall, 'all', 'sort_column',

               'sort_order', 'file', list, optiondates, 
               optioncount, hide_empty, use_desc_for_title, 
               children, child_of, 'Categories', recurse, 
               'feed', 'feed_img', 'exclude', 
               hierarchical); ?> %%%

例子[ ]

默认列表[ ]

使用默认设置,显示类别列表。

<?php list_cats(); ?>

根据类别名分类[ ]

显示类别列表,并没有链接到所有的类别,而且是根据类别名分类的: <?php list_cats(FALSE, ' ', 'name'); ?>

拥有已删除类别的自定义列表[ ]

设置列表不显示所有的类别(以深一层的参数为基础),以升序根据ID分类而且在一个无序类别中(<ul><li>),没有文章发表的日期或者文章的数目,不隐藏内容为空的类别,使用"描述"作为链接的标题,不显示母类别的子类别,而且删除类别1和33:

<?php list_cats(FALSE, '', 'ID',
                'asc', '', TRUE, FALSE, 
                FALSE, FALSE, TRUE, 
                FALSE, FALSE, '', FALSE, 
                '', '', '1,33', 
                TRUE); ?>


使用注意事项[ ]

当为一个无序的列表设置'列表'参数的时候,list_cats()标签自动地以UL开启和关闭,而且每个类别列为一个LI

参数[ ]

optionall
(boolean)设置是否显示一个链接连接到所有的类别。注:WordPress1.5x和2.0版本中不再包含这个功能,但是2.1版本中又重新添加了这个功能。有效的参数值:
  • TRUE (Default)
  • FALSE
所有的
(string)如果 optionall设置为TRUE,这定义了文本显示链接连接到所有的类别。注:WordPress1.5.x和2.0中不再运行这个功能,但是2.1版本中又重新添加了这个功能。默认'所有的'
sort_column
(string)选项分类的关键词。有效的参数值:
  • 'ID' (Default)
  • 'name'
sort_order
(string)选项的分类顺序。有效的参数值:
  • 'asc' (默认的)
  • 'desc'
file
(string) 显示类别链接的php文件。默认'index.php'
list
(boolean) 设置是否在无序的列表中包含类别(<ul><li>)。有效的参数值:
  • TRUE (Default)
  • FALSE


optiondates
(boolean)设置是否显示每个类别中的最后一篇文章的日期。有效的参数值:
  • TRUE
  • FALSE (Default)
optioncount
(boolean)设置是否显示每个类别中文章的数目。有效的参数值:
  • TRUE
  • FALSE (Default)
hide_empty
(boolean) 设置是否隐藏(不显示)不包含文章的类别。有效的参数值:
  • TRUE (Default)
  • FALSE


use_desc_for_title
(boolean) 设置是否将类别描述设置为链接标题(例如 <a title="Category Description" href="...)。有效的参数值:
  • TRUE (Default)
  • FALSE
children
(boolean) 设置是否显示子(子)类别。有效的参数:
  • TRUE
  • FALSE (Default)
child_of
(integer) 只显示这个类别(ID号码)的子类别。没有默认值。
Categories
(integer) 当调用这个模板标签的时候,这个参数应该被设置为0 (零)。(对于那些curious,只有产生层级列表的时候,标签才会内部使用其它参数。)
recurse
(boolean)显示列表(FALSE)或者将列表返回,用在PHP中(TRUE)。默认是FALSE
feed
(string)文本用来显示连接到每个类别的RSS2 feed的链接。默认没有文本,没有显示feed。
feed_image
(string)一个图形的路径/文件名,作为连接到每个类别的RSS2 feed的链接。取消'feed参数。
排除
(string)设置需要被排除的类别。必须是以一个数组的形式出现(ex: 1, 2, 3)。
层级的
(boolean)设置是否在一个层级列表(在母类别之后)中显示子(子)类别。有效的参数值:
  • TRUE (Default)
  • FALSE
注: 在WordPress1.5版本之前的版本中没有层级参数

相关的[ ]

使用查询字符串,传递参数,产生类别的一个列表,请看看wp_list_cats()

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

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