WordPress:Template Tags/single cat title

来自站长百科
Xxf3325讨论 | 贡献2008年6月25日 (三) 10:40的版本 (新页面: == Description == Displays or returns the category title for the current page. For pages displaying WordPress tags rather than categories (e.g. "/tag/geek") the name of the tag is display...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Description

Displays or returns the category title for the current page. For pages displaying WordPress tags rather than categories (e.g. "/tag/geek") the name of the tag is displayed instead of the category. Can be used only outside WordPress:The Loop.

Usage

%%% <?php single_cat_title('prefix', 'display'); ?> %%%

Examples

This example displays the text "Currently browsing " followed by the category title.

<p><?php single_cat_title('Currently browsing '); ?>.</p>
Currently browsing WordPress.


This example assigns the current category title to the variable $current_category for use in PHP.

<?php $current_category = single_cat_title("", false); ?>

Parameters

prefix
(string) Text to output before the category title. Defaults to '' (no text).
display
(boolean) Display the category's title (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.

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