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

WordPress Döngüsünde İstenilen Sayıda Yazı Nasıl Görüntülenir?

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.

Bir WordPress döngüsünde birden fazla blog yazısı mı göstermek istiyorsunuz?

WordPress, döngüyü kullanarak geçerli sayfada görüntülenecek her bir gönderiyi işler. Bunları, döngü etiketleri içinde belirtilen kriterlerle nasıl eşleştiklerine göre biçimlendirir.

Bu makalede, bir WordPress döngüsünde herhangi bir sayıda yazının nasıl görüntüleneceğini göstereceğiz.

How to display any number of posts in a WordPress loop

WordPress Döngüsü Nedir?

Döngü, WordPress tarafından yazılarınızın her birini görüntülemek için kullanılır. WordPress temasında bir web sayfasında yazıların listesini göstermek için kullanılan PHP kodudur. WordPress kodunun önemli bir parçasıdır ve çoğu sorgunun merkezinde yer alır.

Bir WordPress döngüsünde, yazıları görüntülemek için çalışan farklı işlevler vardır. Ancak geliştiriciler şablon etiketlerini değiştirerek her bir gönderinin döngüde nasıl gösterileceğini özelleştirebilirler.

Örneğin, bir döngüdeki temel etiketler bir döngüdeki gönderinin başlığını, tarihini ve içeriğini gösterecektir. Özel etiketler ekleyebilir ve kategori, alıntı, özel alanlar, yazar adı ve daha fazlası gibi ek bilgileri görüntüleyebilirsiniz.

WordPress döngüsü ayrıca her sayfada göstereceğiniz blog yazılarının sayısını kontrol etmenizi sağlar. Bu, her döngüde görüntülenen yazı sayısını kontrol edebileceğiniz için bir yazar şablonu tasarlarken yararlı olabilir.

Bununla birlikte, bir WordPress döngüsüne herhangi bir sayıda yazının nasıl ekleneceğini görelim.

WordPress Döngüsüne İstediğiniz Sayıda Yazı Ekleme

Normalde, döngüde görüntülenecek yazı sayısını WordPress yönetici panelinizden ayarlayabilirsiniz.

WordPress panosundan Ayarlar ” Okuma bölümüne gitmeniz yeterlidir. Varsayılan olarak, WordPress 10 gönderi gösterecektir.

Reading settings WordPress

Ancak, belirli bir WordPress for 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ı geçersiz kılabilirsiniz.

Bu, yazar profilleri, kenar çubukları ve daha fazlası dahil olmak üzere sayfalarınızın görüntüleme ayarlarını özelleştirmenize olanak tanır.

Öncelikle, gönderileri yerleştirmek istediğiniz bir şablon dosyası açmanız ve ardından bu döngüyü eklemeniz gerekecektir:

<?php
// if everything is in place and ready, let's start the loop
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; ?>

Not: Kodun if ( $count == "n " ) kısmındaki‘n‘ değerini değiştirmeniz ve herhangi bir sayı seçmeniz gerekecektir.

Bu kodu WordPress web sitenize eklemenin kolay bir yolu WPCode eklentisini kullanmaktır. WordPress için özel kodu yönetmenize yardımcı olan en iyi kod parçacığı eklentisidir.

WPCode kullanarak, tema şablon dosyalarını manuel olarak düzenlemeniz ve bir şeyleri kırma riskini almanız gerekmez. Eklenti kodu sizin için otomatik olarak ekleyecektir.

Öncelikle, ücretsiz WPCode eklentisini yüklemeniz ve etkinleştirmeniz gerekir. Daha fazla ayrıntı için lütfen bir WordPress eklentisinin nasıl kurulacağına ilişkin kılavuzumuza bakın.

Etkinleştirmenin ardından, WordPress panonuzdan Code Snippets ” + Add Sn ippet’e gidebilirsiniz. Ardından, ‘Özel Kodunuzu Ekleyin (Yeni Snippet)’ seçeneğini seçmeniz gerekir.

Add new snippet

Bundan sonra, yukarıda size gösterdiğimiz WordPress döngüsü için özel kodu ‘Kod Önizleme’ alanına yapıştırmanız yeterlidir.

Ayrıca kodunuz için bir ad girmeniz ve ‘Kod Türü’nü ‘PHP Snippet’ olarak ayarlamanız gerekecektir.

Add custom loop code to WPCode

Ardından, ‘Ekleme’ bölümüne ilerleyebilir ve kodu çalıştırmak istediğiniz yeri seçebilirsiniz.

Varsayılan olarak WPCode, WordPress web sitenizin her yerinde çalışır. Ancak, konumu belirli bir sayfa olarak değiştirebilir veya kodu eklemek için bir kısa kod kullanabilirsiniz.

Edit insertion method for code

Bu eğitim için varsayılan ‘Otomatik Ekleme’ yöntemini kullanacağız.

İşiniz bittiğinde, kodu ‘Aktif’ hale getirmek için üstteki geçişe tıklamayı ve ardından ‘Kaydet’ düğmesine tıklamayı unutmayın. WPCode şimdi kodu WordPress blogunuza dağıtacak ve WordPress döngüsünde belirtilen sayıda gönderiyi görüntüleyecektir.

Bu makalenin bir WordPress döngüsünde istediğiniz sayıda gönderiyi nasıl görüntüleyeceğinizi öğrenmenize yardımcı olduğunu umuyoruz. Ayrıca, WordPress’te yapışkan gönderileri döngüden nasıl çıkar acağınıza ilişkin kılavuzumuzu ve işletme web siteleri için olmazsa olmaz WordPress eklentileri için uzman seçimlerimizi görmek 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.

Açıklama: İçeriğimiz okuyucu desteklidir. Bu, bazı bağlantılarımıza tıklarsanız komisyon kazanabileceğimiz anlamına gelir. WPBeginner'ın nasıl finanse edildiğini, neden önemli olduğunu ve nasıl destek olabileceğinizi görün. İşte editoryal sürecimiz.

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!

Reader Interactions

22 yorumBir Cevap Bırakın

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. THANKGOD JONATHAN says

    This Super Loop concept is a game-changer! I’ve been struggling with displaying the right number of posts, and this is just what I needed.
    Thank you for the helpful post.

  3. Uchenna says

    Please I need help from you guys on how to go about this. the problem is that while i have set a static front page on my Desktop view using a different theme which is Admag magazine and blog theme it appears fine and i like it but my mobile view which i used carrington theme displays nothing & when i try to call up posts on it it displays the link to the page i used on my desktop view which continues to open same link without showing any post. please who can help me find my way here. thanks in advance.
    This is my site please help me. its good on desktop but cant call up posts on mobile front page.

  4. Khaled says

    global $wp_query;
    $args = array_merge( $wp_query->query_vars, array( ‘posts_per_page’ => ‘6’ ) );
    query_posts( $args );
    query_posts( $args );

    Inspired from here

  5. Absarul Haque says

    I want to show 2 Post in Home Pages and 5 Posts in all other archive pages (Like Tag, Category and search results).

  6. Ramon Hitzeroth says

    Thanks for this tutorial. Just one question though, my posts for some reason only show 50 at most on one page, if I set “n” to anything less than 50 it shows only that number of posts but anything more than 50 it stops at 50.

  7. SHWAN NAMIQ SALEEM says

    Thank you very nice code i used this code in my blog to times , to show limit posts in homepage and in sidebar > the code work correctly without any problem . it is very simple code to use

  8. Kirk says

    It seems that, although I can alter the number of posts displayed using your method, the “number of posts setting” in the admin panel under Settings > Reading still sets the maximum.
    So, for instance, if I set that number to 20 in my wp-admin panel and then within my template I set $count to equal any number OVER 20, it will still only show 20 posts. I can, however, set $count in my template to equal a number UNDER 20 and it will only show that amount of posts. So, the number in the admin panel seems to be the maximum. Is there a workaround for this? Thanks

  9. Roy Omwell says

    hi team,
    row #28 is missing “++”. It should be: count++
    otherwise thank you, that was exactly what I was looking.

Bir Cevap Bırakın

Yorum bırakmayı seçtiğiniz için teşekkür ederiz. Lütfen tüm yorumların yorum poli̇ti̇kasi uyarınca denetlendiğini ve e-posta adresinizin yayımlanmayacağını unutmayın. Ad alanında anahtar kelime KULLANMAYIN. Kişisel ve anlamlı bir sohbet edelim.