钩子文档

rest_route_for_post

💡 云策文档标注

概述

rest_route_for_post 是一个 WordPress 过滤器,用于修改或自定义文章在 REST API 中的路由路径。它允许开发者基于文章对象动态调整路由。

关键要点

  • 过滤器名称:rest_route_for_post
  • 参数:$route(路由路径字符串)和 $post(WP_Post 对象)
  • 用途:过滤文章在 REST API 中的路由,常用于自定义路由逻辑或集成第三方服务
  • 相关函数:rest_get_route_for_post() 用于获取文章的路由
  • 引入版本:WordPress 5.5.0

📄 原文内容

Filters the REST API route for a post.

Parameters

$routestring
The route path.
$postWP_Post
The post object.

Source

return apply_filters( 'rest_route_for_post', $route, $post );

Changelog

Version Description
5.5.0 Introduced.