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!
Hata: ".$upload['error']."
";
} 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);
add_post_meta($pid, '_thumbnail_id', $attach_id, true);
return $attach_data; } }
Fonksiyonu bu wp_resim_ekle($resim,$inserted_id,seourl($baslik).".jpg");
Bunuda mysql sorguna koyucaksın.