the_terms()显示一篇文章所属的分类信息

目录

描述

Displays a string of linked terms for a post.

the_terms() 描述

用法

 <?php the_terms$id$taxonomy$before$sep$after ); ?> 

the_terms() 用法

参数

$id

(integer) (mandatory) Post ID.

默认值: 0

$taxonomy

(string) (mandatory) Taxonomy name.

默认值: Empty string

$before

(string) (可选) Text to display before the actual tags are displayed.

默认值: Empty string

$sep

(string) (可选) Text or character to display between each tag link.

默认值: ', '

$after

(string) (可选) Text to display after the last tag.

默认值: Empty string

the_terms() 参数

返回值

(false

Will return false on failure. Otherwise, it displays the linked terms of a custom taxonomies separated by user defined characters, and will not return a value.

the_terms() 返回值

示例

Get Categories of Current Post

Get a list of current post's categories:

The output of above code will be: categories: TV / Speaker / Monitor

the_terms() 示例

注意

the_terms() 注意

历史

添加于 版本: 2.5.0

the_terms() 历史

源文件

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

the_terms() 源文件

相关