Простой способ через шорткод (без плагинов):
В functions.php темы:
function single_gallery_image($atts) {
$atts = shortcode_atts(['id' => 0, 'size' => 'medium'], $atts);
$images = (array) get_post_gallery_images($post->ID, true);
if (empty($images)) return '';
$first_img = $images[0];
$full_img = str_replace('-' . $atts['size'], '', $first_img);
return sprintf(
'<a href="%s" data-gallery="%s">%s</a>',
$full_img,
implode(',', $images), // Вся галерея для lightbox
wp_get_attachment_image(get_the_ID($first_img), $atts['size'])
);
}
add_shortcode('first_gallery_img', 'single_gallery_image');
В посте изай [first_gallery_img] - выводит первую картинку галереи. Клик -> Fancybox/Lightbox покажет всю (подключи JS).
Альтернатива плагин: FooGallery или Modula - галерея с "single preview" из коробки.