参数
- $post_id
-
(int)(必填) 文章 ID
- $taxonomy
-
(string)(必填) 分类法名称(taxonomy name)
- $before
-
(string)(可选) 要在term之前使用的字符串。
默认值: ''
- $sep
-
(string)(可选) 要在term之间使用的字符串。
默认值: ', '
- $after
-
(string)(可选) 要在term后面使用的字符串。
默认值: ''
返回
(void|false) 成功时无返回,失败为false。
源码
更新日志
版本 | 描述 |
---|---|
2.5.0 | 开始引入 |
使用示例
获取当前文章的类别
获取当前文章的类别列表:<?php the_terms( $post->ID, 'category', 'categories: ', ' / ' ); ?>
上述代码的输出可以是:categories: TV / Speaker / Monitor