rest_route_for_post_type_items
云策文档标注
概述
此文档介绍 WordPress 中用于过滤文章类型 REST API 路由的 Hook。它允许开发者自定义 REST API 路由路径,基于文章类型对象进行修改。
关键要点
- Hook 名称:rest_route_for_post_type_items
- 参数:$route(路由路径字符串)和 $post_type(WP_Post_Type 对象)
- 用途:在获取文章类型 REST API 路由时应用过滤器,可修改路由路径
- 相关函数:rest_get_route_for_post_type_items() 用于获取路由
- 引入版本:WordPress 5.9.0
原文内容
Filters the REST API route for a post type.
Parameters
$routestring-
The route path.
$post_typeWP_Post_Type-
The post type object.
Source
return apply_filters( 'rest_route_for_post_type_items', $route, $post_type );
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |