Home » Wordpress » paginate_links does not display the second page

paginate_links does not display the second page

Posted by: admin November 30, 2017 Leave a comment


I want to create a blog page displaying only 5 posts per page and if there are 7 posts the last two posts will display on the second page.

Here is what I have got so far:

<div style="float:left; padding-top: 20px;">
    $args = array( 'numberposts' => '','post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date", 'cat'=>1,'paged' => get_query_var('paged'));
    $postslist = get_posts( $args );
    foreach ($postslist as $post) : setup_postdata($post); 
<div style="float:left;" class="three columns">

    <label style="color:#DB6903;"><?php the_date(); ?></label>
    <?php the_author(); ?><br>
    <?php comments_number(); ?>

    <div style="clear:both;"></div>

<div style="float:left; padding-top: 10px; " class="eight columns" >

    <a href="<?php the_permalink() ?>" target="_parent" style="color: black;">
        <h2 style="font-size: 28px;"><?php the_title(); ?></h2>
    <div class="entry-summary">
        <p>         <?php the_excerpt(); ?></p>

        <img src="wp-content/themes/quaero/images/grey_divider" width="100%"  alt="divider" />

<div style="clear:both;"></div>

<?php endforeach; ?>
</div><aside style="float:left; padding-left: 20px;" class="one-third columns">
    <?php get_sidebar(); ?>
</aside><div style="clear:both;"></div><?php posts_nav_link(); ?>

When I click on the second page, it doesn’t display the last two posts. It still displays the first 5 posts. How can I fix this?

Now posts_nav_link() works. But the navigation displays “« Previous Page Next Page »” even after the second page.


Your query $args doesn’t contain paged parameter.

$args = array( 'numberposts' => '','post_status'=>"publish",'post_type'=>"post",
  'orderby'=>"post_date", 'cat'=>1,'paged' => get_query_var('paged'));