钩子文档

get_attached_media

💡 云策文档标注

概述

get_attached_media 是一个 WordPress 过滤器,用于筛选附加到指定文章的媒体列表。它允许开发者自定义媒体项的返回结果。

关键要点

  • 过滤器名称:get_attached_media
  • 参数:$children(WP_Post[] 数组,表示附加媒体的列表)、$type(字符串,指定媒体类型)、$post(WP_Post 对象,表示目标文章)
  • 返回值:通过 apply_filters 返回数组,可被修改
  • 相关函数:get_attached_media() 用于检索附加媒体
  • 引入版本:WordPress 3.6.0

📄 原文内容

Filters the list of media attached to the given post.

Parameters

$childrenWP_Post[]
Array of media attached to the given post.
$typestring
Mime type of the media desired.
$postWP_Post
Post object.

Source

return (array) apply_filters( 'get_attached_media', $children, $type, $post );

Changelog

Version Description
3.6.0 Introduced.