这就是我使用的函数,也许有更好的方法。
$attachments = get_children(
array(
\'numberposts\' => -1,
\'order\'=> \'ASC\',
\'post_mime_type\' => \'image\',
\'post_parent\' => get_the_ID(),
\'post_type\' => \'attachment\'
));
$first_attachment = reset($attachments);
//$last_attachment = end($attachments); or last image
echo wp_get_attachment_image($first_attachment->ID, \'full\');
其他
wp_get_attachment_image
此处找到的参数:
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image