-1
Hello, I’m trying to call the title of the image, to be displayed in the gallery, but it is called only the title of the first photos and all the others are with the same title, I wonder if they could help me?
Follows my code:
<?php
$imagens_ids = $product->get_gallery_attachment_ids();
$imagens = array();
$imagens[] = get_the_post_thumbnail_url();
foreach ($imagens_ids as $imagem_id) {
$imagens[] = wp_get_attachment_url($imagem_id);
$title = get_post(get_post_thumbnail_id())->post_title;
}
echo '<div class="images galeria-imagens-produto">';
echo '<div class="galeria-maior">';
foreach ($imagens as $imagem) {
echo '<div class="bloco-imagem-maior">';
echo '<div class="h-100 bloco-imagem-maior-interno">';
echo '<a data-fancybox="galeria_'.get_the_ID().'" href="'.$imagem.'">';
echo '<img src="'.$imagem.'" class="h-100 w-100" alt="'.get_the_title($imagem_id).'">';
echo '</a>';
echo'</div>';
echo '<div class="legenda-imagem">';
echo '<p>'.$title.'</p>';
echo'</div>';
echo'</div>';
}
echo'</div>';
echo'</div>';
?>