Mostrar la última imagen subida de un post en WordPress

Antes, cuando quería mostrar la miniatura de una imagen subida en un post de WordPress usaba éste plugin, pero tuve un par de problemas en los últimos desarrollos y terminé optando por usar el siguiente snippet:

<?php
$args = array( 'post_type' => 'attachment', 'post_status' => null, 'post_parent' => get_the_ID() );
$attachments = get_posts($args);
if ($attachments):
$attachment = array_pop($attachments);
$thumb = wp_get_attachment_image_src( $attachment->ID, 'thumbnail');
?>
<a href="<?php the_permalink(); ?>"><img src="<?php echo $thumb[0]; ?>" /></a>
<?php
endif;
?>

Obviamente que debe estar adentro del loop para que funcione, ya que usa la función get_the_ID(). Espero que le sea de utilidad a alguien.