I cannot get pagination to work on my home page code. it keeps displaying the same posts

Please can someone tell me what is wrong with my code and why it keeps showing the same content on the paginated pages?

It has two loops.. the first is for the featured post and then the rest of the posts.

<?php 
 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  $postArgs = array(
      'showposts' => get_option('posts_per_page'),
      'offset' => 0,
      'orderby' => 'post_date',
      'order' => 'DESC',
      'post_type' => 'post',
      'post_status' => 'publish',
      'paged' => $paged);
  $the_query = new WP_Query( $postArgs );
?>
<div id="billboard">
  <?php
    $a = 0;
    while ( $the_query->have_posts() ) : $the_query->the_post();
      if ($a == 0)
      { ?>
<!-- post image -->
<div id="mainPostImage">
    <div class="inner">


        </div>
</div>
<!-- close post image --> 

        <div id="mainPostDetail">
          <div class="content">
            <h2><?php the_title(); ?></h2>
            <h3>by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?></h3>
            <div class="entry-content"><?php the_excerpt(); ?></div>
          </div>
        </div>
      <?php } else {
        break;
      }
      $a++;
    endwhile;
  ?>
</div>

<div id="mainContent">
  <div id="primary">
    <div class="posts">
    <?php
      $b = 0;
      while ( $the_query->have_posts() ) : $the_query->the_post();
        if ($b > 0) { ?>
          <div class="post">
            <span class="post-thumbnail">

        </span>
            <h2><?php the_title(); ?></h2>
            <h3>by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?></h3>
            <div class="entry-content"><?php the_excerpt(); ?></div>
            <div class="entry-meta">
              <?php comments_number( '', 'one Comment', '% Comments' ); ?>
            </div>
          </div> <!-- .post -->
        <?php }

        $b++;
      endwhile;
?>

<div class="nextprev">
<div style="float:right;"><?php next_posts_link('Older Entries  &raquo;', $the_query->max_num_pages) ?></div>
<?php previous_posts_link('&laquo; Newer Entries &raquo;') ?>
</div>

<?php
if($the_query->max_num_pages>1){?>
    <p style="text-align:right;">
    <?php
      if ($paged > 1) { ?>
        <a href="<?php echo '?paged=' . ($paged -1); //prev link ?>"><</a>
                        <?php }
    for($i=1;$i<=$the_query->max_num_pages;$i++){?>
        <a href="<?php echo '?paged=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
        <?php
    }
    if($paged < $the_query->max_num_pages){?>
        <a href="<?php echo '?paged=' . ($paged + 1); //next link ?>">></a>
    <?php } ?>
    </p>
<?php } ?> 

<?php      wp_reset_postdata();
wp_reset_query();
?> 
</div>

Related posts

Leave a Reply

1 comment

  1. Change $postArgs to:

    $postArgs = array('post_type' => 'post', 'paged' => $paged);
    

    Everything else in the array u have up there is default and unnecessary.

    Also add $the_query->rewind_posts(); after the first endwhile;

    Update

    Fix for pagination issues:

    global $wp_query;
    $paged = ($wp_query->query['paged']) ? $wp_query->query['paged'] : 1;