钩子文档

get_post_gallery

💡 云策文档标注

概述

get_post_gallery 是一个 WordPress 过滤器钩子,用于过滤在指定文章内容中找到的第一个图库。它允许开发者修改或扩展图库数据。

关键要点

  • 钩子名称:get_post_gallery
  • 参数:$gallery(第一个找到的图库数组)、$post(文章 ID 或 WP_Post 对象)、$galleries(所有找到的图库的关联数组)
  • 用途:在 get_post_gallery() 函数中调用,用于检查和返回文章内容中的第一个图库
  • 引入版本:WordPress 3.6.0

代码示例

return apply_filters( 'get_post_gallery', $gallery, $post, $galleries );

📄 原文内容

Filters the first-found post gallery.

Parameters

$galleryarray
The first-found post gallery.
$postint|WP_Post
Post ID or object.
$galleriesarray
Associative array of all found post galleries.

Source

return apply_filters( 'get_post_gallery', $gallery, $post, $galleries );

Changelog

Version Description
3.6.0 Introduced.