How to show caption in Gallery images in wordpress

hi I have portfolio blog and under portfolio page, I show my images as image feed and add via gallery its show simply no hyperlink no title no caption

I want to show the only caption on every image

Read More

here is code use to display image in my theme

    <?php 
    global $post;
    $header_images = get_post_meta($post->ID, '_ebor_gallery_images', 1); 

    if( is_array($header_images) ) :
?>

<ul class="basic-gallery text-center">
    <?php 
        foreach( $header_images as $id => $content ){
            echo '<li>'. wp_get_attachment_image($id, 'large') .'</li> ';

        }
    ?>
</ul>

how add caption in this help me out for this

thanks !

Related posts

Leave a Reply

2 comments

  1. Try this…

    <ul class="basic-gallery text-center">
        <?php 
            $output = '';
            foreach( $header_images as $id => $content ){
                $output .= '<li>'. wp_get_attachment_image($id, 'large');
                $image = get_post($id);
                $output .= '<span class="caption>'.$image->post_excerpt.'</span>';
                $output .= .'</li> ';
            }
            echo $output;
            $output = '';
        ?>
    </ul>
    

    Output your caption in whatever container you want, I just used a span as an example.