function wp_resim_ekle($url, $pid, $filename){
	$link_info = pathinfo($url);
	$filetype = wp_check_filetype($url);
	extract($filetype);
	if (!$type) $type = "";
	$upload = wp_upload_bits($filename, $filetype, @file_get_contents($url));
	if (!empty($upload['error']) ) {
		return "Resim eklenemedi!<br>Hata: ".$upload['error']."<br>";
		} else {
		$neyim = $upload['file'];
		$attachment = array(
			'guid' => $upload['url'],
			'post_mime_type' => $type,
			'post_title' => $link_info['basename'],
			'post_content' => '',
			'post_type' => 'attachment',
			'post_parent' => $pid
		);
		require_once ( ABSPATH . 'wp-admin/includes/image.php' );
		$attach_id = wp_insert_attachment($attachment, $neyim, $pid);
		$attach_data = wp_generate_attachment_metadata($attach_id, $neyim);
		wp_update_attachment_metadata($attach_id, $attach_data);
		return $attach_data;
	}
}
	$my_post = array();
	$my_post['post_title'] 		= $baslik;
	$my_post['post_content'] 	= $aciklama;
	$my_post['tags_input'] 		= $etiket;
	$my_post['post_status'] 	= $yayin;
	$my_post['post_author'] 	= 1;
	$my_post['post_category']	= array($kategori);
	
	
	if ($idxx=wp_insert_post($my_post)) {
				for($i=0; $i<count($resimler); $i++){
			$resim	= trim($resimler[$i]);
			wp_resim_ekle($resim,$idxx,md5(rand().time().microtime().rand()).".jpg");
		}
		die('ok');
	}
Bu kodlar yardımcı olur belki. kaydet.php için.