我遇到的问题是我在自己的页面模板上创建了一个单独的新博客页面,称为 blog.php,我在每个页面中提取了 5 个帖子,第一页效果很好,并链接到它们所附加的单个帖子. 当我尝试将 wp-pagenavi 添加到我的 nav-below 中时,我遇到了问题。发生的事情是我将单击转到下一页并更改 url,但帖子与以前保持不变,当它应该将它们切换到下一组时。我不知道您是否可以在 index.php 之外使用 wp-pagenavi,但如果有人可以让我知道我在这里做错了什么以及为什么我继续收到相同的帖子,这些帖子会很棒并且非常受欢迎。我在 blog.php 上有我的一个博客,这就是我要开始工作的文件。我已经在下面发布了。请让我知道我能做些什么谢谢!
<?php
/**
* Template Name: Blog Page
*/
get_header(); ?>
<div id="content">
<?php query_posts("posts_per_page=5"); ?>
<?php
//THE LOOP.
if( have_posts() ):
while( have_posts() ):
the_post(); ?>
<article id="post-1" <?php post_class( 'clearfix' ); ?>>
<h2 class="entry-title"> <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a></h2>
<div class="postmeta">
<span class="author"> Posted by: <?php the_author(); ?> </span>
<span class="date"> <?php the_date(); ?> </span>
<span class="num-comments">
<?php comments_number('No comments yet', 'One comment', '% comments'); ?></span>
<span class="categories">
<?php the_category(); ?>
</span>
<span class="tags">
<?php the_tags(); ?>
</span>
</div><!-- end postmeta -->
<?php if( has_post_thumbnail() ): ?>
<div class="thumb">
<?php the_post_thumbnail( 'thumbnail' ); ?>
</div>
<?php endif; ?>
<div class="entry-content">
<?php
if( is_single()):
the_content();
else:
the_excerpt();
endif;
?>
</div>
<?php comments_template(); ?>
</article><!-- end post -->
<?php
endwhile;
else: ?>
<h2>Sorry, no posts found</h2>
<?php endif; //END OF LOOP. ?>
<div id="nav-below" class="pagination">
<?php if(function_exists('wp_pagenavi')) // if PageNavi is activated ?>
<?php wp_pagenavi(); // Use PageNavi ?>
</div><!-- end #nav-below -->
</div><!-- end content -->
<?php get_footer(); ?>