if($resimyuklenmismi){
set_post_thumbnail( $idm, $resimyuklenmismi );
}
else {
$upload = media_sideload_image($haberresim, $idm, $haberbasligi);
$attachments = get_posts( array(
'post_type' => 'attachment',
'number_posts' => 1,
'post_status' => null,
'post_parent' => $post_id,
'orderby' => 'post_date',
'order' => 'DESC',
) );
$thumbnail_id = $attachments[0]->ID;
preg_match("@src='(.*?)'@si", $upload, $resimurl);
$resimurlyol = trim($resimurl[1]);
if($onecikmis==1){add_post_meta($idm, '_thumbnail_id', $thumbnail_id);}
if(!is_numeric($ozetozelalan)){add_post_meta($idm, $ozetozelalan, $haberozet);}
if($resimozelalan){add_post_meta($idm, $resimozelalan, $resimurlyol);}

}


Örnek