钩子文档

get_object_terms

💡 云策文档标注

概述

get_object_terms 是一个 WordPress 过滤器 Hook,用于修改或过滤与指定对象关联的术语。它允许开发者在检索对象术语时介入处理,常用于自定义术语查询逻辑。

关键要点

  • Hook 名称:get_object_terms,用于过滤对象术语的检索结果。
  • 参数:$terms(术语数组或计数字符串)、$object_ids(对象 ID 数组)、$taxonomies(分类法名称数组)、$args(查询参数数组)。
  • 相关函数:与 wp_get_object_terms() 紧密关联,用于检索对象术语。
  • 版本历史:自 WordPress 4.2.0 版本引入。

代码示例

$terms = apply_filters( 'get_object_terms', $terms, $object_ids, $taxonomies, $args );

📄 原文内容

Filters the terms for a given object or objects.

Parameters

$termsWP_Term[]|int[]|string[]|string
Array of terms or a count thereof as a numeric string.
$object_idsint[]
Array of object IDs for which terms were retrieved.
$taxonomiesstring[]
Array 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

$terms = apply_filters( 'get_object_terms', $terms, $object_ids, $taxonomies, $args );

Changelog

Version Description
4.2.0 Introduced.