Previous and Next pagination in my latest WordPress theme that I'm working on is not working correct...
For example:
I have 5 posts and I have set Blog Pages Show at Most in reading settings to 2 posts... This works fine in index and it shows 2 posts every page...but in my author.php
that I have set my loop to show 12 posts per page, I cannot see my pagination?? I can see my 5 Posts, but I can still navigate between 3 pages through my navigation and every page shows the same 5 posts....This happens in my archive.php
too...
How can I change my Pagination function that works apart from reading settings and shows the pagination buttons whether the posts are more than the number I have set in loop?
Here is my pagination function in my functions.php
:
function infinite_pagination() {
$prev_link = get_previous_posts_link('<span id="newer"><i class="fa fa-angle-left"></i><div>newer posts</div></span>');
$next_link = get_next_posts_link('<span id="older"><div>older posts</div><i class="fa fa-angle-right"></i></span>');
if ($prev_link || $next_link) {
echo '<div class="col-md-12">';
echo '<section class="pagination">';
if ( $prev_link ){
echo $prev_link;
}
if ($next_link){
echo $next_link;
}
echo '</section>';
echo '</div>';
}
}
and here is my loop for author.php
:
<?php get_header(); ?>
<?php $post_query = new WP_Query ( 'posts_per_page=12' );
if($post_query->have_posts() ) : ?>
<?php while($post_query->have_posts() ) : $post_query->the_post(); ?>
<-- Content -->
<?php endwhile; ?>
<?php endif; ?>
<?php infinite_pagination(); ?>
<?php get_footer(); ?>