wmaraci reklam
lidertakipci

Wordpress içerik botu

2 Mesajlar 877 Okunma
advertseo
wmaraci reklam

Ykyazilimmm Ykyazilimmm WM Aracı Kullanıcı
  • Üyelik 17.12.2017
  • Yaş/Cinsiyet 24 / E
  • Meslek Öğrenci
  • Konum Ankara
  • Ad Soyad Y** K**
  • Mesajlar 10
  • Beğeniler 1 / 3
  • Ticaret 1, (%100)
bir siteden veri çeken bot yazdım. siteden başlığı çekiyor title olarak atıyor resmi ve açıklamayı çekip birşeltiriyor ve içerik kısmına yazıyor
ve çekilen resmi de ortam kütüphanesine yüklüyor buraya kadar sıkıntı yok.
ben ortama yüklenen resmi thumbnail olmasını istiyorum yardımcı olabilirmisiniz.




if(isset($_POST["post_content"])){

// echo $_POST["post_content"];
/*
if($dwtbotpro_icerik["image"]){

$attachment_id = dwtbotpro_urlresimcek($dwtbotpro_icerik["image"]);

// print_r(wp_get_attachment_image($attachment_id,"full"));
// $dwtbotpro_icerik["image"] = wp_get_attachment_image($attachment_id,"full");
$yeniResim = wp_get_attachment_image_src($attachment_id,"full");

// print_r($yeniResim);


if(isset($yeniResim[0])){
$html = str_get_html($_POST["post_content"]);
$html->find("img",0)->src = $yeniResim[0];
$_POST["post_content"] = $html->outertext;
}

}
*/


$html = str_get_html($_POST["post_content"]);
if($resimler = $html->find("img")){
foreach($resimler AS $a=>$resim){


$resim->src = preg_replace('~"|\~usmi','',$resim->src);


// echo $resim->src;

$attachment_id = dwtbotpro_urlresimcek($resim->src);
$yeniResim = wp_get_attachment_image_src($attachment_id,"full");

if(isset($yeniResim[0])){
// $html = str_get_html($_POST["post_content"]);
$html->find("img",$a)->src = $yeniResim[0];
$_POST["post_content"] = $html->outertext;
}

}
}

if(!isset($_POST["post_category"])){
$_POST["post_category"] = array(1);
}


// Insert the post into the database
if($postup=wp_insert_post(array(
'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
'post_content' => $_POST["post_content"],
'post_status' => 'publish',
'post_author' => 1,
// 'post_category' => array( 8,39 )
'post_category' => $_POST["post_category"]
))){
echo '
Başarıyla eklendi
';
}else{
echo '
Bir hata oluştu!
';
}
}
}else{
dwtbotpro_mansetler();
}
}


?>
 

 

wmaraci
reklam

s60v3 s60v3 Informatiker Kullanıcı
  • Üyelik 22.07.2014
  • Yaş/Cinsiyet 33 / E
  • Meslek Flutter Developer
  • Konum Mersin
  • Ad Soyad M** A**
  • Mesajlar 247
  • Beğeniler 23 / 77
  • Ticaret 0, (%0)
functions.php içerisinde aşağıdaki kullanılacak
add_theme_support( 'post-thumbnails' );

bu da çekim ve post işlemi yaptığınız sayfa içinde
 

 

Codeigniter&PHP | Vue.js | Dart&Flutter
wmaraci
Konuyu toplam 1 kişi okuyor. (0 kullanıcı ve 1 misafir)
Site Ayarları
  • Tema Seçeneği
  • Site Sesleri
  • Bildirimler
  • Özel Mesaj Al