Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 30, 2011 00:43
Show Gist options
  • Save billerickson/1325306 to your computer and use it in GitHub Desktop.
Save billerickson/1325306 to your computer and use it in GitHub Desktop.
Display Post Image and Caption
<?php
/**
* Display Post Image and Caption
*
* @link http://www.billerickson.net/wordpress-featured-image-captions/
* @author Bill Erickson
*
*/
function be_display_image_and_caption() {
echo '<div class="featured-image">';
the_post_thumbnail();
echo '<span class="caption">' . get_post( get_post_thumbnail_id() )->post_excerpt . '</span>';
echo '</div>';
}
@jdelia
Copy link

jdelia commented Dec 7, 2014

Thanks for this snippet of code. It solved my issue on needing to display a copyright notice on a featured image.

@jdelia
Copy link

jdelia commented Dec 7, 2014

I substituted line 12 for this:
echo get_the_post_thumbnail( $thumbnail->ID, 'feature-wide' );
so I could choose the format size for the image to display above a single post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment