[wp-trac] [WordPress Trac] #12235: Display caption with the_post_thumbnail

WordPress Trac wp-trac at lists.automattic.com
Thu Jan 5 23:34:37 UTC 2012


#12235: Display caption with the_post_thumbnail
-----------------------------+-----------------------------
 Reporter:  hd-J             |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Future Release
Component:  Post Thumbnails  |     Version:  3.3.1
 Severity:  normal           |  Resolution:
 Keywords:                   |
-----------------------------+-----------------------------
Changes (by johnbillion):

 * keywords:  the_post_thumbnail caption wp-caption-text =>


Comment:

 For what it's worth, it's fairly simple to add a function to your theme to
 get the thumbnail caption:

 {{{
 function get_post_thumbnail_caption() {
         if ( $thumb = get_post_thumbnail_id() )
                 return get_post( $thumb )->post_excerpt;
 }
 }}}
 Then you can just do something along the lines of:
 {{{
 if ( has_post_thumbnail() ) {
         the_post_thumbnail( 'medium' );
         echo wpautop( get_post_thumbnail_caption() );
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12235#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list