Category Archives: Uncategorized

WordPress Featured Image

I wanted to modify the way WordPress was displaying my featured image for posts. The desired function is the image shown thumbnail size, to the right on the main page or search results and be a link to the post page. Then, on the post page, remain thumbnail sized and be a link to the full size image. To do this I edit content.php in two places. First, comment out the thumbnail code around line 20 and insert the below code directly after. You will have to repeat this after updating WordPress because this file is overwritten.
<!--Moved Featured Image Start-->

<!–Remember to comment out thumbnail above–>

<a href=”
<?php
if ( is_home() ) {
// This is the blog posts index
the_permalink();
} else {
// This is not the blog posts index
if ( has_post_thumbnail() ) {
$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’ );
echo $full_image_url[0] . ‘” title=”‘ . the_title_attribute( ‘echo=0’ );
//echo get_the_post_thumbnail( $post->ID, ‘medium’ );
}
}
?>
“>

<?php if ( ! post_password_required() && ! is_attachment() ) :
the_post_thumbnail(‘thumb’);
endif; ?></a>
<!–Moved Featured Image End–>