get_the_terms
云策文档标注
概述
get_the_terms 是一个 WordPress 过滤器,用于修改或过滤与指定文章关联的术语列表。它允许开发者在获取文章分类或标签等术语时进行自定义处理。
关键要点
- 过滤器名称:get_the_terms
- 参数:$terms(WP_Term[] 数组或 WP_Error 对象)、$post_id(文章 ID)、$taxonomy(分类法名称)
- 用途:过滤或修改文章关联的术语列表,常用于自定义分类查询或错误处理
- 相关函数:get_the_terms() 用于检索文章的分类术语
- 版本历史:自 WordPress 3.1.0 引入
代码示例
$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
原文内容
Filters the list of terms attached to the given post.
Parameters
Source
$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |