wp_get_object_terms
云策文档标注
概述
wp_get_object_terms 是一个 WordPress 过滤器,用于过滤与指定对象或对象集关联的术语。它允许开发者修改或扩展从 wp_get_object_terms() 函数返回的术语结果。
关键要点
- 过滤器名称:'wp_get_object_terms',用于过滤术语数组或计数。
- 参数包括:$terms(术语数组或计数字符串)、$object_ids(对象ID的逗号分隔列表)、$taxonomies(作为SQL片段的分类法名称)、$args(检索术语的参数数组)。
- 替代建议:推荐使用 'get_object_terms' 过滤器作为替代,因为 $taxonomies 参数以SQL片段格式传递。
- 相关函数:wp_get_object_terms() 用于检索与对象关联的术语。
- 版本历史:自 WordPress 2.8.0 版本引入。
代码示例
return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args );
原文内容
Filters the terms for a given object or objects.
Description
The $taxonomies parameter passed to this filter is formatted as a SQL fragment. The ‘get_object_terms’ filter is recommended as an alternative.
Parameters
$termsWP_Term[]|int[]|string[]|string-
Array of terms or a count thereof as a numeric string.
$object_idsstring-
Comma separated list of object IDs for which terms were retrieved.
$taxonomiesstring-
SQL fragment of taxonomy names from which terms were retrieved.
$argsarray-
Array of arguments for retrieving terms for the given object(s). See wp_get_object_terms() for details.
More Arguments from wp_get_object_terms( … $args )
See WP_Term_Query::__construct() for supported arguments.
Source
return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args );
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |