Created
October 30, 2011 00:43
-
-
Save billerickson/1325306 to your computer and use it in GitHub Desktop.
Display Post Image and Caption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; | |
} |
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
Thanks for this snippet of code. It solved my issue on needing to display a copyright notice on a featured image.