WordPress at a glance

get_post_gallery() WP 1.0

Check a specified post's content for gallery and, if present, return the first

Is the basis for: get_post_gallery_images()
Works based on: get_post_galleries()
✈ 1 time = 0.014229s = extreme slow | 50000 times = 612.03s = extreme slow PHP 7.0.4, WP 4.4.2

No Hooks.

Return

String/Array. Gallery data and srcs parsed from the expanded shortcode.

Usage

get_post_gallery( $post, $html );
$post(int/WP_Post)
Post ID or WP_Post object.
Default: global $post
$html(true/false)
Whether to return HTML or data.
Default: true

Code of get_post_gallery: wp-includes/media.php VER 5.0.1

<?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 );
}

Related Functions

From tag: Gallery

No comments
    Hello, !     Log In . Register