Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
the_category() - 以HTML列表或自定义格式显示文章的类别列表 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / the_category()

the_category( string $separator = '', string $parents = '', int $post_id = false )

以HTML列表或自定义格式显示文章的类别列表


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 2 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 "da3fa25e51008d111052e4f7cd1619a4" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

cat

category 分类more...

themore...


参数

$separator

(string) (可选) 类别之间的分隔符。默认情况下,链接放置在无序列表中。空字符串将导致默认行为。

默认值: ''

$parents

(string) (可选) 如何显示父对象。

默认值: ''

$post_id

(int) (可选) 要检索类别的文章ID。

默认值: false



源码

查看源码 官方文档


更新日志

版本描述
0.71开始引入

使用示例

  • 示例1

    以空格分隔
    列出以空格作为分隔符的类别。

    <?php the_category( ' ' ); ?>
    
  • 示例2

    $parents
     ▪ ‘multiple’ – 显示指向父类别和子类别的单独链接,显示“父/子”关系。(展示父级和子级,链接指向两者)
     ▪ ‘single’ – 仅显示指向子类别的链接,链接文本显示“父/子”关系。(展示父级和子级,但链接仅指向子级)

  • 示例3

    用逗号分隔
    显示指向类别的链接,每个类别用逗号分隔(如果不止一个)。

    <?php the_category( ', ' ); ?>
    
  • 示例4

    用箭头分隔
    显示指向带有箭头(>)的类别的链接分离类别注意:使用时要注意,因为有些观众可能会把>后面的类别解释为前面那个类别的子类别。

    <?php the_category( '> ' ); ?>
    
  • 示例5

    用项目符号分隔
    显示指向类别的链接,其中项目符号(•)分隔类别。

    <?php the_category( '&bull;' ); ?>