Skip to content

Instantly share code, notes, and snippets.

@mbeall
Created January 19, 2013 00:41
Show Gist options
  • Save mbeall/4569953 to your computer and use it in GitHub Desktop.
Save mbeall/4569953 to your computer and use it in GitHub Desktop.
A function that displays the caption for a featured image.
<?php
function the_post_thumbnail_caption() {
global $post;
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
if ($thumbnail_image && isset($thumbnail_image[0])) {
echo '<div class="caption">'.$thumbnail_image[0]->post_excerpt.'</div>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment