WP频繁升级,很多插件未经Wordpress 3.0以上的测试,好不容易找到一个帖子置顶的插件:Featured posts grid,但是小图却无法显示。不过不要紧,经过以下修改就可解决问题:
将下面这一段:
if (has_post_thumbnail($val->ID))
{
$post_details[$key]['post_img_src'] = wp_get_attachment_image_src( get_post_thumbnail_id($val->ID), ‘thumbnail’);
}else{
…..
}
替换为:
$post_details[$key]['post_img_src'][0] = rocklv_attachment_image($val->ID);
并在文件下添加函数rocklv_attachment_image:
function rocklv_attachment_image($postid=0, $size=’thumbnail’) {
if ($postid<1) $postid = get_the_ID();
if ($images = get_children(array(
‘post_parent’ => $postid,
‘post_type’ => ‘attachment’,
‘numberposts’ => 1,
‘post_mime_type’ => ‘image’,)))
foreach($images as $image)
{
$attachment=wp_get_attachment_image_src($image->ID, $size);
return $attachment[0] ;
}
}

