Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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...???

share|improve this question
add comment

1 Answer

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 />'; 
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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