How to use this for featured image thumbnails on your blog page
-
I tweaked this a little to make it output polaroids as the featured image thumbnail for my blog page. You can see an example of this in action at:
https://www.shrouded.space/index.php/essays/
On to how I did it. I put the following code in my theme functions.php file. This function outputs the caption for the featured image so that the polaroid has a proper caption.
/*
* ==================================================
* FEATURED IMAGE CAPTION
* ==================================================
*/
function the_post_thumbnail_polaroid_caption() {
global $post;$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array(‘p’ => $thumbnail_id, ‘post_type’ => ‘attachment’));if ($thumbnail_image && isset($thumbnail_image[0])) {
echo ‘<span>’.$thumbnail_image[0]->post_excerpt.'</span>’;
}
}Next I added this to my theme. I put it in the content.php file, but you could really put it anywhere, so long as it is inside the loop. I had mine float left so that it’s next to the summary and meta information for each article.
<div class=’polaroid-gallery post-featured’ style=’width:200px;’>
” title=”<?php the_post_thumbnail_polaroid_caption(); ?>” class=”polaroid-gallery-item showcaption no-lightbox”><span class=”polaroid-gallery-image” title=”<?php the_post_thumbnail_polaroid_caption(); ?>” style=”background-image: url(<?php echo the_post_thumbnail_url( ‘thumbnail’ ); ?>); width: 150px; height: 150px;”></span>
<br style=”clear: both;” />
</div>
- The topic ‘How to use this for featured image thumbnails on your blog page’ is closed to new replies.