Şöyle dener misiniz

<?php
require_once('wp-admin/includes/image.php');
$sehir = "oludeniz";
include_once 'wp-load.php';
function connect($aq){ $ch=curl_init("$aq"); curl_setopt($ch,CURLOPT_URL,$aq); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_POSTFIELDS,""); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"); $al=curl_exec($ch); curl_close($ch); return $al; }
function cevir($kelime){ $kelime = iconv ("windows-1254", "UTF-8", $kelime); return $kelime; }

$adres = file_get_contents("http://www.*************/$sehir/");
preg_match_all('#<h3><a href="(.*?)" title="(.*?)"#si', $adres, $x1);
$sxs = count ($x1[1]);
for($qq=0;$qq<$sxs;$qq++){ 
flush(); ob_flush(); 
$link   = "http://www.*************".$x1[1][$qq];
$baslik = $x1[2][$qq];
$adrex  = file_get_contents($link);
preg_match_all('#<h2 itemprop="description"(.*?)>(.*?)</h2>#si', $adrex, $x2);
preg_match_all('#<div class="haber_metni">(.*?)<div class="paylassag#si', $adrex, $x3);
preg_match_all('#<meta itemprop="image" content="(.*?)"#si', $adrex, $x4);
preg_match_all('#<meta property="og:video" content="(.*?)"#si', $adrex, $x5);
preg_match_all('#<meta name="keywords" content="(.*?)"#si', $adrex, $x6);

$baslik   = str_replace("&lt;br/&gt;","",strip_tags($baslik));
$aciklama = str_replace("&lt;br/&gt;","",strip_tags($x2[2][0]));
$haber    = preg_replace('#<a.*?>(.*?)</a>#i', '\1', $x3[1][0]);
$resim    = $x4[1][0];
$video    = $x5[1][0];
$etiket   = $x6[1][0];
$kategori = "2";
$tarih    = date("Y-m-d H:i:s");
$seo      = sanitize_title($baslik);

if(empty($baslik) || empty($resim)|| empty($kategori)|| empty($aciklama)){
echo '<div id=notification-warning class=button><font color="orange"><b>Bilgi Eksik!</b></font></div>';
}else{
$varmi=mysql_query("SELECT * FROM wp_posts WHERE post_name='$seo'");
$kontrol=mysql_num_rows($varmi);
if ($kontrol>0) {
echo '<div id=notification-error class=button><font color="red"><b>'.$baslik.' Var!</b></font></div>';
}
else {
$insert_post = array();

$insert_post['post_title'] = $baslik;
$insert_post['post_content'] = $haber;
$insert_post['post_name'] = $seo;
$insert_post['post_status']  = "publish";
$insert_post['post_date']     = $tarih;
$insert_post['post_date_gmt'] = $tarih;
$insert_post['tags_input']   = $etiket;
$insert_post['post_author']  = 1;
$insert_post['post_category']= array($kategori);

if ($pid = wp_insert_post($insert_post))
{
    add_post_meta($pid,'video',$video);
    add_post_meta($pid,'aciklama',$aciklama);
	// Add Featured Image to Post
	$image_url  = $resim;
	$upload_dir = wp_upload_dir(); // Set upload folder
	$image_data = file_get_contents($image_url); // Get image data
	$filename   = basename($image_url); // Create image file name

	// Check folder permission and define file location
	if( wp_mkdir_p( $upload_dir['path'] ) ) {
		$file = $upload_dir['path'] . '/' . $filename;
	} else {
		$file = $upload_dir['basedir'] . '/' . $filename;
	}

	// Create the image  file on the server
	file_put_contents( $file, $image_data );

	// Check image file type
	$wp_filetype = wp_check_filetype( $filename, null );

	// Set attachment data
	$attachment = array(
		'post_mime_type' => $wp_filetype['type'],
		'post_title'     => sanitize_file_name( $filename ),
		'post_content'   => '',
		'post_status'    => 'inherit'
	);

	// Create the attachment
	$attach_id = wp_insert_attachment( $attachment, $file, $pid );

	// Include image.php

	// Define attachment metadata
	$attach_data = wp_generate_attachment_metadata( $attach_id, $file );

	// Assign metadata to attachment
	wp_update_attachment_metadata( $attach_id, $attach_data );

	// And finally assign featured image to post
	set_post_thumbnail( $pid, $attach_id );
echo '<div id=notification-success class=button><font color="green"><b>'.$baslik.' Eklendi..</b></font></div><div style="display:hidden;text-indent:-9999999px;">ok</div>';
}
}
}
ob_end_flush();
}
?>