single_cat_title()获取当前分类的标题,可自定义输出样式

目录

描述

Displays or returns the page title if a category or tag archive is queried. Therefore, the function can be used only outside the loop.

single_cat_title() 描述

用法

 <?php single_cat_title$prefix$display ); ?> 

Default Usage

single_cat_title() 用法

参数

$prefix

(string) (可选) Text to output before the title.

默认值: None

Note: The $prefix argument is currently ignored if the $display argument is false.
See http://core.trac.wordpress.org/ticket/16632

$display

(boolean) (可选) Should the page title be displayed (true) or returned for use in PHP (false).

默认值: true

single_cat_title() 参数

返回值

(string/void

Page title if a category or tag archive is queried and the $display argument is set to false.

single_cat_title() 返回值

示例

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

Currently browsing WordPress.

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

single_cat_title() 示例

注意

single_cat_title() 注意

历史

添加于 版本: Version 0.71

single_cat_title() 历史

源文件

single_cat_title() 函数的代码位于 wp-includes/general-template.php.

single_cat_title() 源文件

相关