paginate_links does not display the second page

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:

Read More
<div style="float:left; padding-top: 20px;">
<?php
    $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>


<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>
    </a>
    <div class="entry-summary">
        <p>         <?php the_excerpt(); ?></p>

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

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

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

Related posts

Leave a Reply

1 comment

  1. 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'));