钩子文档

oembed_request_post_id

💡 云策文档标注

概述

oembed_request_post_id 是一个 WordPress 过滤器钩子,用于在确定 oEmbed 请求的 post ID 时进行过滤。它允许开发者修改或覆盖自动检测到的 post ID。

关键要点

  • 这是一个过滤器钩子,用于过滤 oEmbed 请求中确定的 post ID。
  • 接受两个参数:$post_id(整数类型,表示 post ID)和 $url(字符串类型,表示请求的 URL)。
  • 在 WordPress 4.4.0 版本中引入。

代码示例

$post_id = apply_filters( 'oembed_request_post_id', $post_id, $request['url'] );

注意事项

  • 此钩子主要用于自定义 oEmbed 响应逻辑,例如根据 URL 动态调整 post ID。
  • 相关函数包括 get_oembed_response_data_for_url() 和 WP_oEmbed_Controller::get_item()。

📄 原文内容

Filters the determined post ID.

Parameters

$post_idint
The post ID.
$urlstring
The requested URL.

Source

$post_id = apply_filters( 'oembed_request_post_id', $post_id, $request['url'] );

Changelog

Version Description
4.4.0 Introduced.