Jump to content


Photo
- - - - -

How to display a caption to featured image?


  • Please log in to reply
5 replies to this topic

#1 bencloson

bencloson

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 14 April 2011 - 06:36 PM

Is there an easy hook to display a featured image with caption (on the blog page)? add something like : <?php the_post_thumbnail(); echo ....? Thank you

#2 timlinson

timlinson

    Advocate

  • Members
  • PipPipPipPipPip
  • 1032 posts

Posted 15 April 2011 - 03:50 AM

I don't think you need external coding for this. - when you insert an image into a post, fill in the "Caption" field - and just to the right of the "Insert into Post" button, click the "Use as Featured Image" link Post back if you're looking for something else.

#3 bencloson

bencloson

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 20 April 2011 - 05:27 PM

No. This works only for the images inside the post but not for featured Images (at least with PlatFormPro). I really think that I'll need to add some PHP in the template.postloop.php Someone could help with code to add? Thank you

#4 cmunns

cmunns

    Advocate

  • Members

  • 6537 posts
  • Country: Country Flag

Posted 20 April 2011 - 07:15 PM

You can add the final function from here:

Please Login or Register to see this Hidden Content

and use the_post_thumbnail_caption() to output in the template.postloop.php file right after any reference to the_post_thumbnail()

#5 bencloson

bencloson

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 21 April 2011 - 05:39 PM

It worked Thank you Adam!

#6 dainiswmichel

dainiswmichel

    Super Member

  • Members

  • 189 posts
  • Country: Country Flag

Posted 12 October 2011 - 04:35 AM

i tried adding the code function the_post_thumbnail_caption() { global $post; $thumb_id = get_post_thumbnail_id($post->id); $args = array( 'post_type' => 'attachment', 'post_status' => null, 'post_parent' => $post->ID, 'include' => $thumb_id ); $thumbnail_image = get_posts($args); if ($thumbnail_image && isset($thumbnail_image[0])) { //show thumbnail title echo $thumbnail_image[0]->post_title; //Uncomment to show the thumbnail caption //echo $thumbnail_image[0]->post_excerpt; //Uncomment to show the thumbnail description //echo $thumbnail_image[0]->post_content; //Uncomment to show the thumbnail alt field //$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true); //if(count($alt)) echo $alt; } } from the wordpress forum post mentioned above to the bottom of my functions.php file. as you may be able to tell, i'm a prrty skanky hack who's just guessing for now. anyway, couldn't get the captions to display on the featured image thumbnails.