Masato Maeyama
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.
What am I missing?
Codes to generate post list come before the pagination.
Whole code: post-list.php
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.
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(); } ?>
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();
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.
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 TRIALMembers 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.
Therefor you should firstly check whether your page generates these generic browsing links.