钩子文档

rest_queried_resource_route

💡 云策文档标注

概述

rest_queried_resource_route 是一个 WordPress 过滤器钩子,用于修改当前查询对象的 REST API 路由。它允许开发者在获取 REST 路由时自定义或调整返回的路径字符串。

关键要点

  • 这是一个过滤器钩子,用于过滤当前查询对象的 REST 路由。
  • 参数 $linkstring 是一个带有前导斜杠的路由字符串,或空字符串。
  • 通过 apply_filters 调用,开发者可以添加自定义逻辑来修改路由。
  • 相关函数 rest_get_queried_resource_route() 用于获取该路由。
  • 在 WordPress 5.5.0 版本中引入。

📄 原文内容

Filters the REST route for the currently queried object.

Parameters

$linkstring
The route with a leading slash, or an empty string.

Source

return apply_filters( 'rest_queried_resource_route', $route );

Changelog

Version Description
5.5.0 Introduced.