• 23-02-2013, 11:07:02
    #1
    Merhaba arkadaşlar ben kendime bir bot hazırlıyorum ufak bir yerde takıldım. Bot işiyle uğraşan arkadaşlar bilirler.

    Öncelikle yaptığım uygulamayı anlatayım:

    file_get_contents le çektiğim resmi bir input text aracılığla post ediyorum.

    Wordpressin sitesinden aldığım şu kodlamayı kullanıyorum.
    $wp_filetype = wp_check_filetype(basename($filename), null );
    $attachment = array(
          'post_mime_type' => $wp_filetype['type'],
          'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
          'post_content' => '',
          'post_status' => 'inherit'
      );
    $attach_id = wp_insert_attachment( $attachment, $filename, $new_post );
    update_post_meta($new_post,'_thumbnail_id',$attach_id);
    Resmi yazıya yolluyor ama bozuk geliyor ortada bir resim yok sadece resmin ismi var "film_resmi.jpg" gibi acaba yukarıdaki kodlamanın çalışması için illaki upload mı etmem gerekiyor benim elimde bir link var o linkten yükleme yapmak istiyorum bunun için ne yapmam lazım. Tabi öne çıkan resim olarak ta gözükmesi lazım.
  • 23-02-2013, 11:43:30
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
    $filename "wp-content/uploads/film_resmi.jpg" seklınde olmalı
    $pid konu idsi
      $wp_filetype = wp_check_filetype(basename($filename), null );
      $wp_upload_dir = wp_upload_dir();
      $attachment = array(
         'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $filename ), 
         'post_mime_type' => $wp_filetype['type'],
         'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
         'post_content' => '',
         'post_status' => 'inherit'
      );
      $attach_id = wp_insert_attachment( $attachment, $filename, $pid );
      // you must first include the image.php file
      // for the function wp_generate_attachment_metadata() to work
      require_once(ABSPATH . 'wp-admin/includes/image.php');
      $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
      wp_update_attachment_metadata( $attach_id, $attach_data );
      add_post_meta($pid,'_thumbnail_id',$attach_id);
  • 23-02-2013, 11:54:07
    #3
    Süpersin hocam peki bunu öne çıkan resim olarak nasıl belirleyebilirim.
  • 23-02-2013, 18:36:20
    #4
    Resmi Öne Çıkan Görsel Olarak Nasıl Yükleye Bilirim Arkadaşlar Lütfen Yardım Eder misiniz?