Если нужно переопределить вывод шорткода [gallery], то можно также воспользоваться хуком
post_gallery:
add_filter('post_gallery', 'dco_post_gallery', 10, 3);
function dco_post_gallery($output, $attr, $instance) {
$_attachments = get_posts(array('include' => $attr['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $attr['order'], 'orderby' => $attr['orderby']));
$attachments = array();
foreach ($_attachments as $key => $val) {
$attachments[$val->ID] = $_attachments[$key];
}
if (empty($attachments)) {
return '';
}
ob_start();
foreach ($attachments as $id => $attachment) :
$full = wp_get_attachment_image_url($id, 'full');
$thumbnail = wp_get_attachment_image_url($id, 'thumbnail');
$alt = $attachment->post_excerpt;
?>
<a class="gallery__item f__col" href="<?php echo $full; ?>">
<img src="<?php echo $thumbnail; ?>" class="gallery__item__img" alt="<?php echo esc_attr($alt); ?>" />
</a>
<?php
endforeach;
return ob_get_clean();
}