wordpressimagecaptions

Is there a function to get the caption for an image in wordpress


I'm trying to get the captions from images in Wordpress but I can't find an easy function to grab this bit of information.

Anyone know a way to get this?

Thanks


Solution

  • Turns out captions are stored as post excerpts. So,

    <?php echo $post->post_excerpt; ?>
    

    will print out the caption if you are on the attachment image page (image.php in your theme) and inside the Loop.