get_object_subtype_{$object_type}
云策文档标注
概述
此文档介绍 WordPress 中的动态 Hook get_object_subtype_{$object_type},用于过滤对象子类型标识符。它允许开发者根据对象类型和 ID 修改或返回对象子类型。
关键要点
- Hook 名称是动态的,基于 $object_type(如 blog、post、comment、term、user 等),例如 get_object_subtype_post。
- 参数包括 $object_subtype(对象子类型字符串或空字符串)和 $object_id(对象 ID)。
- 此 Hook 由 get_object_subtype() 函数调用,用于获取特定类型对象的子类型。
- 自 WordPress 4.9.8 版本引入。
原文内容
Filters the object subtype identifier.
Description
The dynamic portion of the hook name, $object_type, refers to the meta object type (blog, post, comment, term, user, or any other type with an associated meta table).
Possible hook names include:
get_object_subtype_blogget_object_subtype_postget_object_subtype_commentget_object_subtype_termget_object_subtype_user
Parameters
$object_subtypestring-
Object subtype or empty string to override.
$object_idint-
ID of the object to get the subtype for.
Source
return apply_filters( "get_object_subtype_{$object_type}", $object_subtype, $object_id );
Changelog
| Version | Description |
|---|---|
| 4.9.8 | Introduced. |