post_gallery

最后更新于:2021-11-27 16:41:25

apply_filters( ‘post_gallery’, string $output, array $attr, int $instance )

Filters the default gallery shortcode output.

参数

$output

(string)
The gallery output. Default empty.

$attr

(array)
Attributes of the gallery shortcode.

$instance

(int)
Unique numeric ID of this gallery shortcode instance.

源文件

文件: gc-includes/media.php

View on Trac

add_filter( 'post_gallery', 'my_gallery_shortcode', 10, 3 );

function my_gallery_shortcode( $output = '', $atts = null, $instance = null ) {
	$return = $output; // fallback

	// retrieve content of your own gallery function
	$my_result = get_my_gallery_content( $atts );

	// boolean false = empty, see http://php.net/empty
	if( !empty( $my_result ) ) {
		$return = $my_result;
	}

	return $return;
}