WordPress:Template Tags/the category

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

描述[ ]

显示一个链接,连接到一个类别或者一篇文章所属的类别。必须在The Loop内部使用这个标签。

用法[ ]

%%% <?php the_category('separator', 'parents' ); ?> %%%

例子[ ]

由空格分开[ ]

这个用法列出了类别,用空格分开。

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

由逗号分开[ ]

显示链接,链接到类别,每个类别是由逗号分开的(前提是有几个类别)

<p>This post is in: <?php the_category(', '); ?></p>

这篇文章在: WordPress, 电脑, 写博客

由箭头分开[ ]

显示链接,连接到类别,用一个箭头(>)分开类别。(注: 使用箭头的时候,应该注意,因为一些读者可能以为后面加上一个&gt的类别; 是前面类别的一个子类别。)

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

Categories: WordPress > 电脑 > 写博客

有一个Bullet分开[ ]

显示链接,连接到类别,用一个bullet (•)将类别分开。

%%%

文章 类: <?php the_category(' &bull; '); ?>

%%%

Post Categories: WordPress电脑写博客

参数[ ]

分开符
(string)每个类别链接之间显示的文本或者字符。默认是将链接放入一个无序的列表中。


母:(string)怎样显示子(子)类别中的链接。选项有:
  • 'multiple(多个)' -先母子类别分开显示链接,展示"母/子"关系。
  • 'single(单一的)' -只显示链接到子类别的链接,用链接文本展示"母/子"关系。

:注:默认情况是一个链接连接到子类别,没有显示关系。

相关的[ ]

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