Reputation: 5403
How do I link a post's featured image to its full size version on a category page?
Here is my loop on my category.php:
<h1>Professional Portfolio Gallery - <?php single_cat_title(); ?></h1>
<p><?php echo category_description(); ?></p>
<?php if (have_posts()) : ?>
<ul class="portfolio">
<?php while (have_posts()) : the_post(); ?>
<li>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
<?php the_excerpt(); ?></li>
<?php endwhile; ?>
</ul>
<?php wp_paging(); ?>
<?php else : ?>
<h1>Not Found</h1>
<p><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
<?php endif; ?>
Any help would be appreciated!
Upvotes: 0
Views: 3144
Reputation: 411
To link Post Thumbnails to the full size version you should be able to use the following:
<?php
if ( has_post_thumbnail()) {
$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
echo '<a href="' . $full_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
the_post_thumbnail('thumbnail');
echo '</a>';
}
?>
You can find out more about this redirect here: http://codex.wordpress.org/Function_Reference/the_post_thumbnail
Hope that helps!
Upvotes: 3