Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
single_cat_title() - 显示或检索类别存档的页面标题 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / single_cat_title()

single_cat_title( string $prefix = '', bool $display = true )

显示或检索类别存档的页面标题


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "a5b1222dbf5579dcde889eb3f6fe3a4a" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "d72d698f01562a7325d1d265501633b1" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "6a1059d1ab68b376b5ba76e2650231eb" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "901a9de269b560520bcd8dd78854aca2" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

cat

category 分类more...

single

titlemore...


描述

用于在类别模板文件显示类别页面标题。前缀不会自动在前缀之间放置空格,因此如果应该有空格,则参数值需要将其放在末尾。


参数

$prefix

(string) (可选) 标题前面显示的内容,前缀。

默认值: ''

$display

(bool) (可选) 是显示还是检索标题。

默认值: true


返回

(string|void) 当检索时,返回标题。



源码

查看源码 官方文档


更新日志

版本描述
0.71开始引入

使用示例

  • 示例1

    示例
    此示例显示文本“Currently browsing ”,后跟类别标题。

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

    结果:

    Currently browsing WordPress.

    本例将当前类别标题分配给变量$current_category,以便在PHP中使用。

    <?php $current_category = single_cat_title("", false); ?>
    
  • 示例2

    示例:如果要从类别页面中删除标题中的“Category:”只需复制并粘贴到 functions.php 即可。

    function wporg_remove_category_title( $title ) {
        if ( is_category() ) {
            $title = single_cat_title( '', false );
        }
        return $title;
    }
    add_filter( 'remove_the_archive_title', 'wporg_remove_category_title' );