… that damn “echo” statement.
Boy do I feel sheepish. In case anyone needs the right code in the future…
<a href="<?php echo get_attachment_link(get_post_thumbnail_id($post->ID)) ?>">
<?php the_post_thumbnail(array(200,150)); ?></a>
UPDATE: I found the get_attachment_link() function which should take me to the attachment.php page. However, nothing is returning from the function.
Here is the code that I am using:
<a href="<?php get_attachment_link(get_post_thumbnail_id($post->ID)) ?>"><?php the_post_thumbnail(array(200,150)); ?></a>
<?php the_post_thumbnail_caption(); ?>
<?php echo get_attachment_link(get_post_thumbnail_id($post->ID));?>
The first get_attachment_link() outputs nothing, but the second one outputs the link that I want to use. I am assuming the_post_thumbnail() loads $post->ID, so how do I preload $post->ID before calling to the thumbnail?