• 29-08-2010, 22:19:23
    #1
    Wordpress te post içinde
    elle yüklenmiş bir resim var ise (yani thumbnail) onu yayınlamasını,
    yok ise özel alandan eklenmiş resim varsa onu göstermesini
    oda yok ise resim basmamasını

    sağlayacak döngüyü yapmaya çalışıyorum yardım edebilirseniz sevinirim. Sanırım kırmızı renk kod, o bahsettiğim elle yüklenen thumbnaili gösteriyor.

    <?php if (have_posts()) : ?>
    <?php $count = 0; ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $count++; ?>
    <?php if ($count == 1) : ?>
    <h1 class="topstory-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array( 402,210 ), array( 'class' => 'img-topstory' )); ?></a>
    <div style="clear: both;"></div>
    <?php the_content_rss('', TRUE, '', 26); ?>
    <div style="clear: both; margin: 0px 0px 20px 0px;"></div>
    <h1 class="wpsn-list">More <?php single_cat_title(''); ?></h1>
    <?php else : ?>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array( 80,80 ), array( 'class' => 'img-thumb' )); ?></a>	
    <h1 class="normal"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    <?php the_content_rss('', TRUE, '', 21); ?>
    <div style="clear: both; margin: 0px 0px 5px 0px;"></div>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php else : ?>
    <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>
  • 29-08-2010, 23:58:18
    #2
    temanızın functions.php dosyasına aşağıdaki kodu ekleyin

    function get_thumbnail($postid=0, $size='full') {
    if ($postid<1)
    $postid = get_the_ID();
    $thumb = get_post_meta($postid, "resim", TRUE);
    if ($thumb != null or $thumb != '') {
    echo $thumb;
    }
    elseif ($images = get_children(array(
    'post_parent' => $postid,
    'post_type' => 'attachment',
    'numberposts' => '1',
    'post_mime_type' => 'image', )))
    foreach($images as $image) {
    $thumbnail=wp_get_attachment_image_src($image->ID, $size);
    ?>
    <?php echo $thumbnail[0]; ?>
    <?php
    }
    else {
    echo get_bloginfo ( 'stylesheet_directory' );
    echo '/images/resim-yok.jpg';
    }
    }

    temada kullanımı


    <?php echo get_thumbnail($post->ID);?>
    özel alan resmini gösterir / özel alan resmi yoksa yazıdaki kayıtlı ilk resmi gösterir/ hiç resim yoksa tamadaki /images/resim-yok.jpg sabit resimi gösterir

    sabit resimi 1x1 boş transpparan gif yaparsanız hiç bir şeyde görtermeye bilir



    $thumb = get_post_meta($postid, "resim", TRUE); "resim" bölümünü kullandığınız özel alan ismi ile değiştirin
  • 30-08-2010, 01:35:03
    #3
    teşekkür ederim dostum
    sayende echo ların icine nasıl kod ekleyebileceğimide öğrendim.
  • 02-09-2010, 13:48:06
    #4
    Üyeliği durduruldu
    çok guzel iş. teşekkurler..