registered_post_type
云策文档标注
概述
registered_post_type 是一个 WordPress 动作钩子,在自定义文章类型注册后触发。它允许开发者在注册后执行自定义操作,常用于扩展或修改文章类型行为。
关键要点
- 触发时机:在 register_post_type 函数成功注册文章类型后立即执行。
- 参数:接受两个参数:$post_type(字符串,文章类型名称)和 $post_type_object(WP_Post_Type 对象,包含注册参数)。
- 使用场景:适合在 init 钩子中调用,避免过早注册导致问题。
- 功能支持:文章类型可支持多种核心功能,如元框、自定义字段、缩略图等,通过 $supports 参数配置。
注意事项
- 确保在 init 钩子或之后注册文章类型,以避免初始化问题。
- 从 WordPress 4.6.0 版本起,$post_type 参数改为接受 WP_Post_Type 对象,需注意兼容性。
原文内容
Fires after a post type is registered.
Parameters
$post_typestring-
Post type.
$post_type_objectWP_Post_Type-
Arguments used to register the post type.
Source
do_action( 'registered_post_type', $post_type, $post_type_object );