get_post_gallery( int|WP_Post $post, bool $html = true )
Check a specified post’s content for gallery and, if present, return the first
Description Description
Parameters Parameters
Return Return
(string|array) Gallery data and srcs parsed from the expanded shortcode.
Source Source
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 ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
If there is no gallery present in the page, the function will return
false
(boolean).Example
Output each image in a gallery with our own custom image class when using data output and not HTML:
Expand full source codeCollapse full source code
Example data output