• 16-06-2013, 18:37:34
    #1
    Üyeliği durduruldu
    Ben Bir WP Botu Yapıyorum.

    Blogumda thumbnail Özelliği Var . 400 Tane film çekiyorum ancak,hepsine tek tek resim eklemem Mümkün olmuyor.Siteden Çekerken,Resimleri de çekiyorum. Yazıyı,PHP ile yayınlıyorum.


    $my_post = array();
    $my_post['post_title'] = $c2[3][$a];
    $my_post['post_content'] = $s;
    $my_post['post_status'] = 'publish';
    $my_post['post_author'] = 1;
    $my_post['tags_input'] = str_replace(" ",",",$c2[3][$a]);
    $my_post['post_category'] = array($category_id); //Kategorinizin idsini 8 olan yere yazınız.
    $my_post['post_thumbnail'] = $resim;

    $the_post_idit = wp_insert_post( $my_post );

    Gibi Bir Şey Yapmaya Çalışıyorum Böylece,$resim değişkenindeki url yi thumbnail olarak ayarlamak istiyorum.Bu Konuda herhangi Bir Fikri Olan Varsa Yardımcı Olabilir mi
  • 16-06-2013, 22:27:21
    #2
    Bence; özel alanla resim url ekletip, bunları thumbnail yerine çekebilirsin.
    Yoksa yanlış mı anladım bilmiyorum.
  • 17-06-2013, 17:21:15
    #3
    hocam bende bunu arıyorum. çok basit bir şey değil muhtemelen. aldığım resmi sunucuya attım ve db de ne kadar alan varsa eklettim ama yine de olmadı. Bunun için basit bir kod var ama çözemedim bende.
  • 17-06-2013, 17:57:33
    #4
    add_post_meta() yı şu şekilde kullanın hocam:
    $my_post = array();
    $my_post['post_title'] = $c2[3][$a];
    $my_post['post_content'] = $s;
    $my_post['post_status'] = 'publish';
    $my_post['post_author'] = 1;
    $my_post['tags_input'] = str_replace(" ",",",$c2[3][$a]);
    $my_post['post_category'] = array($category_id); //Kategorinizin idsini 8 olan yere yazınız.
    $my_post['post_thumbnail'] = $resim;
    
    $the_post_idit = wp_insert_post( $my_post );
    # $the_post_idit insert edilen yazının id sidir.
    add_post_meta($the_post_idit, 'resim', $resim);
    şöyle de bir fonksiyon tanımlayın :
    function resim($yazi_id) {
    	$resim = get_post_meta($yazi_id, 'resim', true);
    	$cikti = '<img src="'.$resim.'" />';
    	echo $cikti;
    }
    döngünün içerisinde kullanırsınız :
    <?php resim($post->ID); ?>