WordPress:Template Tags/the category head

来自站长百科
Xxf3325讨论 | 贡献2008年6月25日 (三) 10:39的版本 (新页面: {{Deprecated}} == Description == Displays the name of a category if it's different from the previous category. This tag must be used within WordPress:The Loop. == Replace With == T...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

模板:Deprecated

Description

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

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

<?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:

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

Usage

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

Example

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

<h2><?php the_category_head('Category: '); ?></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).

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