Checks a specified post’s content for gallery and, if present, return the first
Parameters
Source
foreach ( $matches[0] as $match ) { $html[] = $match; } } return $html; } /** * Retrieves galleries from the passed post's content. * * @since 3.6.0 * * @param int|WP_Post $post Post ID or object. * @param bool $html Optional. Whether to return HTML or data in the array. Default true. Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |
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:
Example data output