函数原型
get_post_gallery( int|WP_Post $post, bool $html = true ): string|array
函数描述
Checks a specified post’s content for gallery and, if present, return the first
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Optional - Post ID or WP_Post object. Default is global $post.
-
$html
bool
Optional - Whether to return HTML or data. Default is true.
Default:
true
函数返回值
string|array Gallery data and srcs parsed from the expanded shortcode.
函数位置
File: wp-includes/media.php.
函数源码
function get_post_gallery( $post = 0, $html = true ) {
$galleries = get_post_galleries( $post, $html );
$gallery = reset( $galleries );
/**
* Filters the first-found post gallery.
*
* @since 3.6.0
*
* @param array $gallery The first-found post gallery.
* @param int|WP_Post $post Post ID or object.
* @param array $galleries Associative array of all found post galleries.
*/
return apply_filters( 'get_post_gallery', $gallery, $post, $galleries );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |

