Wordpress页面模板不使用分页,工作显示下一个和上一个链接在最新和最旧的帖子之间来回,以及put / page / 2也显示相同的帖子。
以下是代码: -
<div id="homeContentLeft">
<h1>Latest Posts</h1>
<?php
rewind_posts();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'posts_per_page' => 1,
'cat' => 1,
'paged' => $paged
);
query_posts($args);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="entry">
<a href="<?php the_permalink() ?>">
<div id="homeNewsThumbnail">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('thumbnail');
}
?>
<div id="homeNewsBoxDate">
<large><?php the_time('j') ?></large>
<small><?php the_time('M') ?></small>
</div>
</div>
</a>
<div id="homeNewsBox">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php echo substr(get_the_excerpt(), 0,320); ?>...
<readmore> <a href="<?php the_permalink() ?>">> Read More</a></readmore>
</div>
<div style="clear:both"></div>
</div>
<?php endwhile; ?>
<?php wp_reset_query();?>
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
<?php else : ?>
<h2>Not Found</h2>
<div class="inner-entry">
<p>Sorry, but you are looking for something that isn't here.</p>
</div>
<?php endif; ?>
</div>
非常感谢任何帮助!
谢谢
〜亲切的问候
答案 0 :(得分:1)
看起来你的rewind_posts()
函数正在重置循环。所以你的get_query_var()
电话总是从头开始。尝试在 rewind_posts()
$paged = get_query_var(...
希望有所帮助