2011-01-25 26 views

cevap

45

İçinde bu döngü ile yeni bir sayfa şablonu oluşturabilirsiniz:

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$args = array('post_type' => 'post', 'posts_per_page' => 10, 'paged' => $paged); 
$wp_query = new WP_Query($args); 
while (have_posts()) : the_post(); ?> 
    <h2><?php the_title() ?></h2> 
<?php endwhile; ?> 

<!-- then the pagination links --> 
<?php next_posts_link('&larr; Older posts', $wp_query ->max_num_pages); ?> 
<?php previous_posts_link('Newer posts &rarr;'); ?> 
+0

Çekicilik gibi çalışır! –

1

Biraz daha süslü bir çözüm @Gavins Diğerleri için

<?php 
/* 
Template Name: List-all-chronological 
*/ 

function TrimStringIfToLong($s) { 
    $maxLength = 60; 

    if (strlen($s) > $maxLength) { 
     echo substr($s, 0, $maxLength - 5) . ' ...'; 
    } else { 
     echo $s; 
    } 
} 

?> 

<ul> 
<?php 
$query = array('posts_per_page' => -1, 'order' => 'ASC'); 
$wp_query = new WP_Query($query); 

if (have_posts()) : while (have_posts()) : the_post(); ?> 
<li> 
    <a href="<?php the_permalink() ?>" title="Link to <?php the_title_attribute() ?>"> 
     <?php the_time('Y-m-d') ?> 
     <?php TrimStringIfToLong(get_the_title()); ?> 
    </a> 
</li> 
<?php endwhile; else: ?> 
<p><?php _e('Sorry, no posts published so far.'); ?></p> 
<?php endif; ?> 
</ul> 
+1

10'dan fazla mesaj için sayfalandırma nasıl eklenir? –

11

cevap dayalı düşünen insanları Googling this ... Sitenizin ön sayfasını bir statik sayfası ile değiştirdiyseniz, ancak yine de gönderi listenizde görünmesini istiyorsanız er ayrı bir bağlantı yapmanız gerekir:

  1. Okuma> boş bir sayfa oluşturun (ve istediğiniz herhangi bir URL/kurşunu belirtin) Ayarları altında
  2. , senin "Yayınlar sayfasında"
  3. olarak bu yeni sayfayı seçmek

Bu sayfadaki menüyü tıkladığınızda, tüm son gönderilerinizi listelemelisiniz (kodla uğraşmak gerekmez).

+0

Cevabınız için teşekkürler! Hızlı soru: Bunu yaptıktan sonra sayfanın şablonunu nasıl düzenlersiniz? –

İlgili konular