Skip to content

Instantly share code, notes, and snippets.

@jwdsign
Created September 10, 2014 09:23
Show Gist options
  • Save jwdsign/9fb1304775055ef17ddc to your computer and use it in GitHub Desktop.
Save jwdsign/9fb1304775055ef17ddc to your computer and use it in GitHub Desktop.
Post Thumbnail Descriptions
<?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