分页在wordpress中的归档页面中不起作用

时间:2016-03-22 09:16:16

标签: wordpress

每次分页链接都会带我到第一页。我尝试使用或不使用插件,但没有任何作用。如果我点击下一个按钮或上一个按钮,它总是带我到第一页。

<?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>

1 个答案:

答案 0 :(得分: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>