wordpresstr
Administrator
- 125
- 13 Kas 2020
WordPress tarafından gönderilerinizin her birini görüntülemek için kullanılır. The Loop'u kullanarak, WordPress, geçerli sayfada görüntülenecek her gönderiyi işler ve bunları The Loop etiketlerindeki belirli kriterlere nasıl uyduklarına göre biçimlendirir. Normalde, görüntülenecek gönderi sayısı, okumalar sekmesinin altındaki WordPress Yönetici Paneli Ayarları alanınızda belirlenir. Ancak bu makalede, söz konusu WordPress döngüsünde istediğiniz sayıda gönderiyi görüntülemenize olanak tanıyan bir Süper Döngü kullanarak bu sayıyı nasıl geçersiz kılacağınızı göstereceğiz. Bu, yazar profilleri, kenar çubukları ve daha fazlası dahil olmak üzere sayfalarınızın görünümünü özelleştirmenize olanak tanır.
Gönderileri yerleştirmek istediğiniz bir şablon dosyası açın ve ardından bu döngüyü ekleyin:
Ve bitirdiniz. Bu kod, yazarın şablonunu tasarlarken özellikle size çok yardımcı olacaktır çünkü her döngüde görüntülenen gönderi sayısını kontrol etmek isteyebilirsiniz.
Gönderileri yerleştirmek istediğiniz bir şablon dosyası açın ve ardından bu döngüyü ekleyin:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | // if everything is in place and ready, let's start the loop <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> // to display 'n' number of posts, we need to execute the loop 'n' number of times // so we define a numerical variable called '$count' and set its value to zero // with each iteration of the loop, the value of '$count' will increase by one // after the value of '$count' reaches the specified number, the loop will stop // *USER: change the 'n' to the number of posts that you would like to display <?php static $count = 0; if ($count == "n") { break; } else { ?> // for CSS styling and layout purposes, we wrap the post content in a div // we then display the entire post content via the 'the_content()' function // *USER: change to '<?php the_excerpt(); ?>' to display post excerpts instead <div class="post"> <?php the_title(); ?> <?php the_content(); ?> </div> // here, we continue with the limiting of the number of displayed posts // each iteration of the loop increases the value of '$count' by one // the final two lines complete the loop and close the if statement <?php $count++; } ?> <?php endwhile; ?> <?php endif; ?> |
Ve bitirdiniz. Bu kod, yazarın şablonunu tasarlarken özellikle size çok yardımcı olacaktır çünkü her döngüde görüntülenen gönderi sayısını kontrol etmek isteyebilirsiniz.