On this page
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
Parameters
Return
string|array Gallery data and srcs parsed from the expanded shortcode.
Source
File: wp-includes/media.php. View all references
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 );
}
Hooks
- apply_filters( 'get_post_gallery',
array $gallery ,int|WP_Post $post ,array $galleries ) -
Filters the first-found post gallery.
Related
Uses
| Uses | Description |
|---|---|
| get_post_galleries() wp-includes/media.php | Retrieves galleries from the passed post’s content. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| get_post_gallery_images() wp-includes/media.php | Checks a post’s content for galleries and return the image srcs for the first found gallery. |
Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_post_gallery