son konuları listelerken?(+r10)
2
●208
- 29-01-2016, 00:31:44Kimlik doğrulama veya yönetimden onay bekliyor.$i = 0;
if (have_posts () ) : while ( have_posts () ) : the_post (); $i++;
if ($i=== "1") {
echo '<div class="ikili">';
the_title();
} else {
echo '<div class="dortlu">';
the_title();
}
endwhile; endif;
Telefonla yazdım. Hata olabilir. Ama mantık budur.
Kolay gelsin.. - 29-01-2016, 00:38:57Offset kullanabilirsiniz, örnek verecek olursam
<?php query_posts( 'posts_per_page=2' ); if (have_posts()) : while (have_posts()) : the_post(); ?> normal kodlar the_title(); vs <?php endwhile; endif; wp_reset_query(); ?>
Yukarıda ki kod son 2 yazıyı çeker.
<?php query_posts( 'posts_per_page=4&offset=2' ); if (have_posts()) : while (have_posts()) : the_post(); ?> normal kodlar the_title(); vs <?php endwhile; endif; wp_reset_query(); ?>
Yukarıdaki kod ise son 4 yazıyı çeker ama son 2 yazıyı eleyerek.
Örneğin yazı listemiz:
1-) Selam 1
2-) Selam 2
3-) Selam 3
4-) Selam 4
5-) Selam 5
6-) Selam 6
Birinci kod çıktısı :
Selam 1
Selam 2
İkinci kod çıktısı :
Selam 3
Selam 4
Selam 5
Selam 6
Umarım anlatabilmişimdir : )