• 19-05-2017, 13:03:10
    #1
    Eski yazılarda, yazı içerisindeki ilk resmin öne çıkan resim olarak değişmesini istiyorum. Sadece eski yazılarda, bir sefere ahsus yapmam gereken bir işlem. Nasıl olur? Ne yapmam gerekir?
  • 19-05-2017, 13:50:00
    #2
    Bu isinizi görür hocam. Functions.php'ye ekleyin.

    function auto_featured_image() { 
        global $post; 
     
        if (!has_post_thumbnail($post->ID)) { 
            $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); 
             
    	  if ($attached_image) { 
                  foreach ($attached_image as $attachment_id => $attachment) { 
                       set_post_thumbnail($post->ID, $attachment_id); 
                  } 
             } 
        } 
    } 
    // Use it temporary to generate all featured images 
    add_action('the_post', 'auto_featured_image'); 
    // Used for new posts 
    add_action('save_post', 'auto_featured_image'); 
    add_action('draft_to_publish', 'auto_featured_image'); 
    add_action('new_to_publish', 'auto_featured_image'); 
    add_action('pending_to_publish', 'auto_featured_image'); 
    add_action('future_to_publish', 'auto_featured_image');
  • 19-05-2017, 15:17:20
    #3
    d3nnis adlı üyeden alıntı: mesajı görüntüle
    Bu isinizi görür hocam. Functions.php'ye ekleyin.

    function auto_featured_image() { 
        global $post; 
     
        if (!has_post_thumbnail($post->ID)) { 
            $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); 
             
    	  if ($attached_image) { 
                  foreach ($attached_image as $attachment_id => $attachment) { 
                       set_post_thumbnail($post->ID, $attachment_id); 
                  } 
             } 
        } 
    } 
    // Use it temporary to generate all featured images 
    add_action('the_post', 'auto_featured_image'); 
    // Used for new posts 
    add_action('save_post', 'auto_featured_image'); 
    add_action('draft_to_publish', 'auto_featured_image'); 
    add_action('new_to_publish', 'auto_featured_image'); 
    add_action('pending_to_publish', 'auto_featured_image'); 
    add_action('future_to_publish', 'auto_featured_image');

    wp codex bilmediğimden souyorum, bu genel olarak kullanılan resmi otomatik öne çıkan resim yapma kodu mu? Çünkü bana lazım olan tam olarak bu değil. Sadece eski yazılardaki, sadece ilk reimlerini öne çıkan yapmak ve tek sefer işlem yapıp kaldırmak istiyorum.

    Bunun için bazı pluginler yapılmış ama ya çalışmıyor ya da benim istediğim özelliği pro sürümlerinde 15-20 eurolarla veriyorlar.
  • 19-05-2017, 15:37:27
    #4
    kullandiktan sonra sunu silmeniz yeterli olacaktir:

    // Use it temporary to generate all featured images
    add_action('the_post', 'auto_featured_image');
    Sonrasinda manuel olarak eklemeye devam edebilirsiniz. Fakat Twentyeleven temasiyla denedigimde calisti, kendi gelistirdigim baska bir temayla ise calismadi. Onu belirteyim
  • 19-05-2017, 15:44:03
    #5
    d3nnis adlı üyeden alıntı: mesajı görüntüle
    kullandiktan sonra sunu silmeniz yeterli olacaktir:

    // Use it temporary to generate all featured images
    add_action('the_post', 'auto_featured_image');
    Sonrasinda manuel olarak eklemeye devam edebilirsiniz. Fakat Twentyeleven temasiyla denedigimde calisti, kendi gelistirdigim baska bir temayla ise calismadi. Onu belirteyim
    Teşekkürler, deneyeyim inşâallâh.
  • 19-05-2017, 20:14:23
    #6
    Maalesef işimi görmedi. Set All First Images As Featured eklentisini kullandım, tek tek her ayın klasörünü seçip hedef klasör belirleyerek ilerliyorsunuz... Epeyce zaman aldı ve sonuçta ilk resimleri öne çıkan olarak kaydetti ama öne çıkan resimleri direkt /uploads/resim.jpg şeklinde linkledi... O da işe yaramadı yani.
  • 19-05-2017, 22:25:13
    #7
    Sunu deneyin hocam; http://mirnu.com/2016/10/12/wordpres...st-image-post/