那真是太疯狂了!接受函数中的大小是毫无意义的,因为它只返回post对象的数组。
一旦你有了自己的职位,
然后
使用适当的附件功能获取所需附件大小的信息。
我会提出一个这样的函数来代替它;
function get_images($overrides = '', $exclude_thumbnail = false)
{
return get_posts(wp_parse_args($overrides, array(
'numberposts' => -1,
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'exclude' => $exclude_thumbnail ? array(get_post_thumbnail_id()) : array(),
'orderby' => 'menu_order ID'
)));
}
并付诸实践;
<?php if ($photo = get_images('numberposts=1', true)): ?>
<img src="<?php echo wp_get_attachment_url($photo[0]->ID); ?>" alt="fullimg" />
<?php endif; ?>
更新:在函数中输入错误-已修复。