-
Üyelik
20.03.2014
-
Yaş/Cinsiyet
31 / E
-
Meslek
öğrenci
-
Konum
Konya
-
Ad Soyad
N** O**
-
Mesajlar
55
-
Beğeniler
7 / 12
-
Ticaret
0, (%0)
iyi forumlar,bir konuda yardımınıza ihtiyacım var.Wordpress botu yapmaya çalışıyorum kendimce.
wp_insert_post fonksiyonu ile ekleyebiliyorum fakat öne çıkarılmış görseli bir türlü yapamadım.Yardımlarınızı bekliyorum
Php ile wordprese öne çıkarılmış görsel nasıl eklenir.?
1 kişi bu mesajı beğendi.
-
Üyelik
20.03.2014
-
Yaş/Cinsiyet
31 / E
-
Meslek
öğrenci
-
Konum
Konya
-
Ad Soyad
N** O**
-
Mesajlar
55
-
Beğeniler
7 / 12
-
Ticaret
0, (%0)
hocam php konusunda pek iyi olduğum söylenemez,bana sadece post girerken öne çıkarılmış görseli nasıl ekleyeceğimi söylermisinz.mesela
'post_title' => 'Başlık', başlığı bu şekilde ekliyoruz.bunun gibi öne çıkarılmış görsel ekleyemezmiyiz ?
-
Üyelik
20.04.2013
-
Yaş/Cinsiyet
34 / E
-
Meslek
Web Programcılığı
-
Konum
Trabzon
-
Ad Soyad
** **
-
Mesajlar
97
-
Beğeniler
0 / 15
-
Ticaret
3, (%67)
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.