0

I Follow this code to make a gallery photo system:

$the_imgs = get_custom_field('gallery_img:to_array');
foreach( $the_imgs as $img )
{
    list( $url, $width, $height ) = wp_get_attachment_image_src( $img, 'thumbnail' );
    echo '<img src="' . $url . '" width="' . $width . '" height="' . $height . '"><br />'; 
}

but I wanna to show my caption photos, someone can help me...???

1 Answer 1

0

You should be able to use the caption from post_excerpt of the WP_Post object.

$the_imgs = get_custom_field('gallery_img:to_array');
foreach( $the_imgs as $img )
{
    list( $url, $width, $height ) = wp_get_attachment_image_src( $img, 'thumbnail' );
    $img_post = get_post( $img );
    echo '<img src="' . $url . '" width="' . $width . '" height="' . $height . '"> ' . $img_post->post_excerpt . '<br />'; 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.