我被困住了。我一直在尝试使用query_posts( array('category_name'=>'news','posts_per_page' => 2, 'paged' => $paged)
问题是它在第一页上返回了正确的结果,当我转到较旧的查询$wp_query->request
查询时,而不是显示LIMIT 2,2
显示LIMIT 10,10
,表明它正在进行每页使用默认帖子。
<?php
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1; } query_posts( array('category'=>'news','posts_per_page' => 4, 'paged' => $paged));
if (have_posts()) : ?> <div class="arch-wrap">
<?php
while ($query->have_posts()) :
$query->the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php
the_title_attribute(); ?>"><?php
the_title(); ?></a></h2>
<span class="top-post-meta"><small>Posted on
<?php the_time('F j, Y') ?> by <?php
the_author() ?></small></span>
<div class="cover">
<div class="entry">
<?php ?><div style="margin-left:10px;"class="image-frame page-image-frame fr"><?php //echo wp_get_post_image();?></div><?php
?><?php get_post_excerpt(500) ?>
</div>
</div>
<div class="clear"></div>
</div>
<?php endwhile; ?> </div>
<div id="navigation">
<?php
wp_reset_query(); if(function_exists('wp_pagenavi')) {
wp_pagenavi(); } ?> </div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p>Sorry, but there are currently no posts found here.</p>
<?php endif; ?>
</div> <?php get_sidebar('right');
?> <?php get_footer(); ?>