• 16-06-2019, 11:59:00
    #1
    aşağıdaki kod ile wordpress sitesinde yazı içerisindeki görseli otomatik olarak öne çıkan görsel yapıyorum. ama yazıya girdiğimde 2 tane oluyor. yani bir öne çıkan görsel birde postun görseli alt altagelmiş oluyor. yapmak istediğim single postta bu görseli teke düşürmek nasıl yapabilirim?
    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');
  • 17-06-2019, 23:00:36
    #2
    Merhaba,

    single.php de öne çıkan görseli gösteren kodu silebilirsiniz. Aksi halde her halükarda hem öne çıkan görsel hem de yazı içindeki görsel görünecektir.