Advertisement
alchymyth

get_post_thumbnail_caption()

Jun 5th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * @package Wordspop
  4.  * @subpackage Fotofolio_Landscape
  5.  */
  6.  
  7. add_theme_support('webfont');
  8.  
  9. /**
  10.  * Load initial WPop script
  11.  */
  12. require_once dirname(__FILE__) . '/libs/wpop/init.php';
  13.  
  14. function get_post_thumbnail_caption() {
  15.   global $post;
  16.  
  17.   $thumb_id = get_post_thumbnail_id($post->id);
  18.  
  19.   $args = array(
  20.     'post_type' => 'attachment',
  21.     'post_status' => null,
  22.     'post_parent' => $post->ID,
  23.     'include'  => $thumb_id
  24.     );
  25.  
  26.    $thumbnail_image = get_posts($args);
  27.  
  28.    if ($thumbnail_image && isset($thumbnail_image[0])) {
  29.      //show thumbnail title
  30.      //return $thumbnail_image[0]->post_title;
  31.  
  32.      //Uncomment to show the thumbnail caption
  33.      return $thumbnail_image[0]->post_excerpt;
  34.  
  35.      //Uncomment to show the thumbnail description
  36.      //return $thumbnail_image[0]->post_content;
  37.  
  38.      //Uncomment to show the thumbnail alt field
  39.      //$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
  40.      //if(count($alt)) return $alt;
  41.   }
  42.   else {
  43.     return false;
  44.   }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement