Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Kupası
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Nedir: Döngü

Editoryal Not: WPBeginner üzerindeki ortak bağlantılardan komisyon kazanıyoruz. Komisyonlar, editörlerimizin görüşlerini veya değerlendirmelerini etkilemez. Editoryal Süreç hakkında daha fazla bilgi edinin.

‘Döngü’ genellikle ‘WordPress döngüsü’ veya sadece ‘döngü’ olarak da adlandırılır. Bir WordPress web sitesinde yazıları görüntüleyen anahtar PHP kodu parçasıdır.

WordPress döngüsü, WordPress kodunun tartışmasız en önemli yönlerinden biridir ve şu ya da bu şekilde çoğu sorgunun merkezinde yer alır.

What Is a Loop in WordPress?

İnfografik: WordPress Döngüsünü Anlamak

Döngü, WordPress temalarında bir web sayfasında yazıların bir listesini görüntülemek için kullanılır.

Tema geliştiricileri, döngü içindeki her bir gönderinin nasıl görüntüleneceğini özelleştirmek için şablon etiketleri kullanarak çıktıyı biçimlendirebilir. Birkaç şablon etiketi yalnızca WordPress döngüsü içinde çalışır ve gönderi verilerini biçimlendirmek, düzenlemek ve yayınlamak için kullanılır.

Yeni başlayanlar için WordPress Döngüsünü parçalara ayırmak için aşağıdaki infografiği oluşturduk.

Infographic - Understanding the WordPress Loop

Kod Örneği: Basit Bir WordPress Döngüsü

Bir örnek görmek isteyebilirsiniz.

İşte basit bir WordPress döngüsü oluşturmak için kullanılan bazı PHP kodları:

<?php
 
// checks if there are any posts that match the query
if (have_posts()) :
 
  // If there are posts matching the query then start the loop
  while ( have_posts() ) : the_post();
 
    // the code between the while loop will be repeated for each post
    ?>
 
    <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
 
    <p class="date-author">Posted: <?php the_date(); ?> by <?php the_author(); ?></p>
 
    <?php the_content(); ?>
 
    <p class="postmetadata">Filed in: <?php the_category(); ?> | Tagged: <?php the_tags(); ?> | <a href="<?php comments_link(); ?>" title="Leave a comment">Comments</a></p>
 
    <?php
 
    // Stop the loop when all posts are displayed
 endwhile;
 
// If no posts were found
else :
?>
<p>Sorry no posts matched your criteria.</p>
<?php
endif;
?>

Umarız bu makale WordPress döngüsü hakkında daha fazla bilgi edinmenize yardımcı olmuştur. Faydalı WordPress ipuçları, püf noktaları ve fikirleriyle ilgili makaleler için aşağıdaki Ek Okuma listemize de göz atmak isteyebilirsiniz.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Ultimate WordPress Araç Kiti

Araç setimize ÜCRETSİZ erişim sağlayın - her profesyonelin sahip olması gereken WordPress ile ilgili ürün ve kaynaklardan oluşan bir koleksiyon!