• 06-07-2014, 22:28:15
    #1
    Görmüş olduğum bazı wordpress bloglarda yazıları listelerken ilk yazıyı daha ön plana çıkartıyorlar. İlk yazı için thumbnail daha büyük oluyor vesaire, yani farklı still özellikleri atıyorlar. Ama bunun ardından gelen 2,3 ve 4. yazılarda ise thumbnail daha küçük oluyor, bunu da farklı bir stille yapıyorlar.

    Bunun nasıl yapıldığını merak ediyorum.

    	<?php query_posts('showposts=4&orderby=date&cat=110'); ?>
    Ben bloğumda 110 nolu kategoriye ait en son yazılmış 4 yazıyı listeleyebiliyorum. Bunu ikiye ayırsak, bir div içine sadece ilk yazıyı çeksek, ardından bir div daha açıp burada da 2,3 ve 4. yazıları çeksek cssle yapılabilir sanırım.

    Peki bu ayırma işlemini nasıl yapacağız? Yine aynı kodla
    	<?php query_posts('showposts=1&orderby=date&cat=110'); ?>
    şeklinde ilk yazıyı çekeriz ama 2,3 ve 4. yazıları nasıl çekeceğiz?
  • 06-07-2014, 22:36:23
    #2
    <?php
    $postcount = 1;
    if (have_posts()) : while (have_posts()) : the_post();

    if ($postcount==1) {
    // ilk post
    ?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php
    } else {
    // sonraki postlar
    ?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php
    $postcount++;
    endwhile;
    ?>
    <?php else : ?>
    <h2>Not Found</h2>
    <?php endif; ?>
  • 06-07-2014, 22:42:32
    #3
    fireelf adlı üyeden alıntı: mesajı görüntüle
    <?php 
    $postcount = 1;
    if (have_posts()) : while (have_posts()) : the_post(); 
    
    if ($postcount==1) {
    // ilk post
    ?>
    	<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    	<?php the_content(); ?>
    <?php 
    } else { 
    // sonraki postlar
    ?>
    	<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    	<?php the_content(); ?>
    <?php
    $postcount++;
    endwhile; 
    ?>
    <?php else : ?>
    	<h2>Not Found</h2>
    <?php endif; ?>
    //sonraki postlar'dan sonra geriye kalan tüm postları getiriyor galiba. 2,3,4. yazılar gelmesi için ne yapmalıyız?
    php bilgim yok malesef.
  • 06-07-2014, 22:47:45
    #4
    Bu bloğu kopyalayarak istediğini postu özelleştirebilirsiniz.

    <?php
    // 2.post
    if ($postcount==2) {
    ?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php } ?>

    <?php
    // 3.post
    if ($postcount==3) {
    ?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php } ?>

    <?php
    // 4.post
    if ($postcount==4) {
    ?>
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php } ?>