get_post_gallery

The timeline below displays how wordpress function get_post_gallery has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Checks a specified post's content for gallery and, if present, return the first
 *
 * @since 3.6.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @param bool        $html Optional. Whether to return HTML or data. Default is true.
 * @return string|array Gallery data and srcs parsed from the expanded shortcode.
 */
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);
}

WordPress Version: 4.6

/**
 * Check a specified post's content for gallery and, if present, return the first
 *
 * @since 3.6.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @param bool        $html Optional. Whether to return HTML or data. Default is true.
 * @return string|array Gallery data and srcs parsed from the expanded shortcode.
 */
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);
}

WordPress Version: 4.2

/**
 * Check a specified post's content for gallery and, if present, return the first
 *
 * @since 3.6.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @param bool        $html Optional. Whether to return HTML or data. Default is true.
 * @return string|array Gallery data and srcs parsed from the expanded shortcode.
 */
function get_post_gallery($post = 0, $html = true)
{
    $galleries = get_post_galleries($post, $html);
    $gallery = reset($galleries);
    /**
     * Filter 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);
}

WordPress Version: 4.0

/**
 * Check a specified post's content for gallery and, if present, return the first
 *
 * @since 3.6.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @param bool        $html Whether to return HTML or data.
 * @return string|array Gallery data and srcs parsed from the expanded shortcode.
 */
function get_post_gallery($post = 0, $html = true)
{
    $galleries = get_post_galleries($post, $html);
    $gallery = reset($galleries);
    /**
     * Filter 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);
}

WordPress Version: 3.9

/**
 * Check a specified post's content for gallery and, if present, return the first
 *
 * @since 3.6.0
 *
 * @param int|WP_Post $post Optional. Post ID or object.
 * @param bool        $html Whether to return HTML or data.
 * @return string|array Gallery data and srcs parsed from the expanded shortcode.
 */
function get_post_gallery($post = 0, $html = true)
{
    $galleries = get_post_galleries($post, $html);
    $gallery = reset($galleries);
    /**
     * Filter 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);
}

WordPress Version: 3.7

/**
 * Check a specified post's content for gallery and, if present, return the first
 *
 * @since 3.6.0
 *
 * @param mixed $post Optional. Post ID or object.
 * @param boolean $html Whether to return HTML or data
 * @return string|array Gallery data and srcs parsed from the expanded shortcode
 */
function get_post_gallery($post = 0, $html = true)
{
    $galleries = get_post_galleries($post, $html);
    $gallery = reset($galleries);
    return apply_filters('get_post_gallery', $gallery, $post, $galleries);
}