WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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.