WordPress:Template Tags/the category head

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

模板: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 the name of a category if it's different from the previous category. This tag must be used within WordPress:The Loop.

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

Replace With

取代

This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag.

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

To display the name of the category when on a category page, use:

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

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

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

To display category name(s) on a single post page, this code block (which would need to run in WordPress:The Loop) provides an example:

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

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

<?php

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


Usage

用法

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

%%% <?php the_类别_标头('之前', '之后'); ?> %%%

Example

例子

Displays the text "Category: " followed by the name of the category.

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

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

<h2><?php the_类别_标头('类别: '); ?></h2>

Parameters

参数

before
(string) Text to output before the category. Defaults to '' (no text).
after
(string) Text to output after the category. Defaults to '' (no text).
之前
(string) 类别之前的文本。默认T '' (没有文本)。
之后
(string) 类别之后的文本。默认'' (没有文本)。

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