Link to home
Start Free TrialLog in
Avatar of Masato Maeyama
Masato MaeyamaFlag for Japan

asked on

Pagination does not show in custom page on WordPress site

I don't figure out how to make a Pagination plugin work properly

Purpose:
I want to create a post list page, where all posts are displayed. This page will have pagination at footer.
To implement pagination, I installed WP-PageNavi plugin.
https://wordpress.org/plugins/wp-pagenavi/#description

Current Situation:
- According to sample code shown above, I put the line in the code to show pagination, but it does not show.
 <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>  

Open in new window


What am I missing?

Codes to generate post list come before the pagination.

Whole code: post-list.php
/* Post list generation - START*/
<?php
$paged = (int) get_query_var('paged');
$args = array(
        'posts_per_page' => 10,
        'paged' => $paged,
        'orderby' => 'post_date',
        'order' => 'DESC',
        'post_type' => 'post',
        'post_status' => 'publish'
);
$the_query = new WP_Query($args);
if ( $the_query->have_posts() ) :
        while ( $the_query->have_posts() ) : $the_query->the_post();
?>
        <div class="news-item">
          <div>
            <a href="#" class="news-item-title"><?php the_title(); ?></a>
            <p class="news-item-desc"><?php the_excerpt(); ?></p>
            <a class="more-link" href="<?php the_permaLink(); ?>">Read more</a>
          </div>
        </div>

/* Pagination here */
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?> 
<?php endwhile; endif; ?>

<?php wp_reset_postdata(); ?>

<?php
get_footer();

Open in new window


Preview site: http://54.178.243.12/%E3%83%8B%E3%83%A5%E3%83%BC%E3%82%B9%E4%B8%80%E8%A6%A7/

Any advice would be very appreciated.
Avatar of Hagay Mandel
Hagay Mandel
Flag of Israel image

The plugin your'e using is a replacement for the generic post browsing wp mechanism:
Want to replace the old ← Older posts | Newer posts → links with some page links? This plugin provides the wp_pagenavi() template tag which generates fancy pagination links.
Therefor you should firstly check whether your page generates these generic browsing links.
Avatar of Masato Maeyama

ASKER

Thank you for your comment. I stop using the plugin and implemented pagination with WordPress native features.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.