The WordPress codex on wp_get_attachment_link says you can use the $permalink parameter to link to the page, not the image. But I would like to link to the post instead. I'm trying to get a list of images using the following (updated, see answers below):
<?php $new_query = new WP_Query('&showposts=1'); ?>
<?php while ($new_query->have_posts()) : $new_query->the_post(); ?>
<?php $args = array (
'post_type' => 'attachment',
'numberposts' => 1418,
'orderby' => 'date',
'status' => 'publish',
'post_mime_type' => 'image',
'parent' => $post->ID
); ?>
<?php $attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
echo '<li>';
echo wp_get_attachment_link'<a href=" ' . get_permalink( $post->ID ) . '">';
echo wp_get_attachment_image($attachment->ID, 'thumbnail', true, '');
echo '</a></li>';
}
};
endwhile;
?>