Filter hook 'get_post_gallery'

in WP Core File wp-includes/media.php at line 5417

View Source

get_post_gallery

Filter Hook
Description
Filters the first-found post gallery.

Hook Information

File Location wp-includes/media.php View on GitHub
Hook Type Filter
Line Number 5417

Hook Parameters

Type Name Description
array $gallery The first-found post gallery.
int|WP_Post $post Post ID or object.
array $galleries Associative array of all found post galleries.

Usage Examples

Basic Usage
<?php
// Hook into get_post_gallery
add_filter('get_post_gallery', 'my_custom_filter', 10, 3);

function my_custom_filter($gallery, $post, $galleries) {
    // Your custom filtering logic here
    return $gallery;
}

Source Code Context

wp-includes/media.php:5417 - How this hook is used in WordPress core
<?php
5412  	 *
5413  	 * @param array       $gallery   The first-found post gallery.
5414  	 * @param int|WP_Post $post      Post ID or object.
5415  	 * @param array       $galleries Associative array of all found post galleries.
5416  	 */
5417  	return apply_filters( 'get_post_gallery', $gallery, $post, $galleries );
5418  }
5419  
5420  /**
5421   * Retrieves the image srcs from galleries from a post's content, if present.
5422   *

PHP Documentation

<?php
/**
	 * 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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/media.php
Related Hooks

Related hooks will be displayed here in future updates.