Created
September 10, 2014 09:23
-
-
Save jwdsign/9fb1304775055ef17ddc to your computer and use it in GitHub Desktop.
Post Thumbnail Descriptions
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 | |
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])) { | |
echo $thumbnail_image[0]->post_excerpt; | |
} | |
function the_post_thumbnail_description() { | |
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])) { | |
echo $thumbnail_image[0]->post_content; | |
} | |
} | |
function the_post_thumbnail_alt() { | |
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])) { | |
$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true); | |
if(count($alt)) echo $alt; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment