WordPress:Template Tags/the category head

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

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.


描述[ ]

如果类别与前一个类别不同,就要显示这个类别名。必须在The Loop内部使用这个标签。

取代[ ]

当WordPress中添加多个类别的时候,这个标签就被取消了,而且没有一对一的对等标签。

要在一个类别网页上显示类别名,请使用:

<?php echo get_the_category_by_ID($cat); ?>

要在一个单独的文章网页上显示类别名,这个代码块(需要运行The Loop)提供了一个例子:

<?php

foreach(get_the_category() as $category) {
    echo $category->cat_name . ' '; 
}
?>

用法[ ]

%%% <?php the_category_head('before', 'after'); ?> %%%

例子[ ]

在类别名之前显示文本"Category: "。

<h2><?php the_category_head('Category: '); ?></h2>

参数[ ]

before
(string) 类别之前的文本。默认T '' (没有文本)。
after
(string) 类别之后的文本。默认'' (没有文本)。

相关的[ ]

模板:标签类别标签

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