2016-03-22 35 views
0

Her sayfalandırma bağlantıları beni her seferinde ilk sayfaya götürür. Eklenti ile veya eklenti olmadan denedim ama hiçbir şey işe yaramıyor. Bir sonraki butona veya önceki düğmeye basmamın önemi yok, beni her zaman ilk sayfaya götürür.Pagination, wordpress arşiv sayfasında çalışmıyor

<?php 
    /* 
    Template Name: Notices & Circulars 
*/ 
get_header(); ?> 
    <div class="banner-box"> 
    <div class="wrap"><div class="main-top"><div class="main"> 
    <h1><div class="titlepage"><?php the_title();?></div></h1> 
    <section class="content"> 
<?php 
    $args=array(
'cat'=> 14, 
'posts_per_page' => 10, 
'offset' => 5, 
'paged' => get_query_var('page') 
); 
if (have_posts()) : 
query_posts($args); 
?> 
<?php while(have_posts()):the_post();?> 
<li style="list-style:none;"> 
     <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ? >"><font style="color:#666666;"><?php the_title(); ?></a></h3> 
     <?php 
    /*****  Thumbnail  ******/ 
    the_post_thumbnail(
    array(120, 90), 
    array(

    'class' => 'thumbnail', 
    'alt' => 'post thumbnail', 
    'title' => 'my custom title' 
) 
); 
/*******  Thumbnail Ends ********/ 
the_content(__('Continue Reading'));?></font>   
    </li><hr /><?php 
endwhile; 
wp_pagenavi(); 
endif; 
?></div></div></div><?php 
get_footer();?></div> 

cevap

1
Please try this: 
<?php 
    /* 
    Template Name: Notices & Circulars 
*/ 
get_header(); ?> 
    <div class="banner-box"> 
    <div class="wrap"><div class="main-top"><div class="main"> 
    <h1><div class="titlepage"><?php the_title();?></div></h1> 
    <section class="content"> 
<?php 
// Example for adding WP PageNavi to a new WP_Query call 
$paged = get_query_var('paged') ? get_query_var('paged') : 1; 
$args = array('post_type' => 'post','cat'=> 14,'posts_per_page' => 10, 'paged' => $paged); 
$loop = new WP_Query($args); 
while ($loop->have_posts()) : $loop->the_post(); 
    ?> 
    <li style="list-style:none;"> 
     <h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><font style="color:#666666;"><?php the_title(); ?></a></h3> 
     <?php 
    /*****  Thumbnail  ******/ 
    the_post_thumbnail(
    array(120, 90), 
    array(

    'class' => 'thumbnail', 
    'alt' => 'post thumbnail', 
    'title' => 'my custom title' 
) 
); 
/*******  Thumbnail Ends ********/ 
the_content(__('Continue Reading'));?></font>   
    </li><hr /> 
    <?php 
endwhile; ?> 

<?php wp_pagenavi(array('query' => $loop)); ?> 
</div></div></div> 
<?php get_footer();?></div> 
+0

İşe yaradı! Ama bir sorum var, neden 'offset' kaldırıldı. Kodunuza geri koymaya çalıştım, sonra sayfalama işlemim durdu Ama yine de offset'i kaldırdığımda tekrar çalışmaya başladım! Ofset neden sorun yaratıyor? – Rishabh

+1

ofset, WordPress'e yayın çekmeye nereden başlayacağını söyleyen bir parametreden başka bir şey değildir. İlk sayfadaysanız, ofset sıfır olmalıdır. İkinci sayfadaysanız, daha önce görüntülediğiniz birçok gönderi (sıfırdan başlayacağımıza göre daha az bir sayı) olmalıdır. Yine de, ofset kullanmak isterseniz, bu tür bir kodu kullanabilirsiniz: $ display_count = 10; $ offset = ($ sayfa - 1) * $ display_count; $ args = dizi ('post_type' => 'post', 'cat' => 4, 'posts_per_page' => 10, 'offset' => $ offset, 'paged' => $ paged); –

+0

Teşekkürler Mohod Sandhya! Bilgini gerçekten takdir ediyorum :-) – Rishabh

İlgili konular