My current theme supports Gallery Post Formats. The Gallery format takes all images from the gallery and displays them in a slideshow. I want to be able to add the caption and photo credit line to the bottom of each image as it changes for the information to change along with it.
The current gallery format template looks like this:
<?php if ( has_post_format( 'gallery' ) ) : ?>
<div class="gallery-post-format">
<?php
$galleries = get_post_gallery_images( $post );
$output = '<ul class="gallery-images">';
foreach ($galleries as $gallery) {
$output .= '<li>' . '<img src="'. $gallery . '">' . '</li>';
}
$output .= '</ul>';
echo $output;
?>
</div>
<?php endif; ?>
I am wanting to add the following code to display the captions and photo credit line to each image.
<div>
<?php
$photographer_name = get_post_meta(get_post_thumbnail_id(), 'be_photographer_name', true);
$photographer_url = get_post_meta(get_post_thumbnail_id(), 'be_photographer_url', true);
if ( $photographer_name ) : ?>
<div id="tgg_credit_line" class="tgg-photo-credit" align="right">
📷 Image Credit /
<?php if ( $photographer_url ) : ?>
<a href="<?php echo $photographer_url ?>">
<?php endif; ?>
<?php echo $photographer_name ?>
<?php if ( $photographer_url ) : ?>
</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div id="tgg_image_caption" class="tgg-image-caption" align="left">
<?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?>
</div>
</div>
How can I do this?