简体   繁体   中英

Pagination is not working in archive page in WordPress

Every pagination link take me to the first page every time. I have tried with or without a plugin, but nothing works. It doesn't matter if I click on the Next button or the Prev button. It always takes me to the first page.

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM