post_gallery
Filters the default gallery shortcode output.
If the filtered output isn't empty, it will be used instead of generating the default gallery template.
Использование
add_filter( 'post_gallery', 'wp_kama_post_gallery_filter', 10, 3 );
/**
* Function for `post_gallery` filter-hook.
*
* @param string $output The gallery output.
* @param array $attr Attributes of the gallery shortcode.
* @param int $instance Unique numeric ID of this gallery shortcode instance.
*
* @return string
*/
function wp_kama_post_gallery_filter( $output, $attr, $instance ){
// filter...
return $output;
}
- $output(строка)
- The gallery output.
По умолчанию: '' - $attr(массив)
- Attributes of the gallery shortcode.
- $instance(int)
- Unique numeric ID of this gallery shortcode instance.
Список изменений
| С версии 2.5.0 | Введена. |
| С версии 4.2.0 | The $instance parameter was added. |
Где вызывается хук
wp-includes/media.php 2740
$output = apply_filters( 'post_gallery', '', $attr, $instance );