Allows plugins and themes to override the default gallery template, ie. what the gallery shortcode returns.
Hook into the gallery shortcode and replace its output with your own.
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;
}
add_filter( 'post_gallery', 'my_gallery_shortcode', 10, 3 );
This function is applied once, in wp-includes/media.php
- in gallery_shortcode() on line 1648