有人能告诉我我的代码有什么问题吗?为什么它总是在分页的页面上显示相同的内容?
它有两个循环。。首先是针对特色帖子,然后是其他帖子。
<?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 »\', $the_query->max_num_pages) ?></div>
<?php previous_posts_link(\'« Newer Entries »\') ?>
</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>