看这里:
if($row->type==\'post\'){
$result = wp_get_attachment_image_src ($attachment_id, \'medium\');
$url_img = $result[\'url\'];
$permalink = get_permalink($row->id);
}
您正在使用
attachment_id
变量,但您尚未在任何地方启动它。
if($row->type==\'post\'){
$attachment_id = get_post_thumbnail_id($row->id);
$result = wp_get_attachment_image_src ($attachment_id, \'medium\');
$url_img = $result[\'url\'];
$permalink = get_permalink($row->id);
}