作者和类别档案的分页无法正常工作
我制作了一个底部有分页的类别页面。每次我尝试转到第 2 页时,URL 结构都会发生变化,但循环中的帖子不会发生变化。博客页面的分页工作正常,循环几乎完全相同。有什么提示我可能做错了什么吗?我也在使用 Wp-Paginate 插件。
<ul class="blogpostings">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post();?>
<li>
<?php if ( has_post_thumbnail() ):?>
<?php
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id, 'thumbnail', true);
echo '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '"><img src="' . $image_url[0] . '" title="' . get_the_title($post->ID) . '" alt="' . get_the_title($post->ID) . '" /></a>';
?>
<?php endif; ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2><br/>
<h3><?php the_author_posts_link(); ?> <span class="date">| <?php the_time('F d, Y') ?> |</span> <?php comments_popup_link('Post Comment', '1 Comment »', '% Comments »'); ?>
<fb:like href="<?php the_permalink() ?>" layout="button_count" width="100" font="lucida grande"></fb:like>
</h3>
<?php the_excerpt(); ?>
<p class="postreadmore"><a href="<?php the_permalink() ?>" class="arrow"> Read More </a></p>
</li>
<?php endwhile; ?>
</ul>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
<?php if(function_exists('wp_paginate')) {
wp_paginate();
} ?>
<?php } ?>
<?php endif; ?>
</div>
I've made a category page that has pagination on the bottom of it. Everytime i try to go to page 2, the URL structure changes but the posts from my loop do not. The pagination is working fine for the blog page with almost the exact same loop. Any hints to what I could be doing wrong? I am also using the Wp-Paginate plug in.
<ul class="blogpostings">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post();?>
<li>
<?php if ( has_post_thumbnail() ):?>
<?php
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id, 'thumbnail', true);
echo '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '"><img src="' . $image_url[0] . '" title="' . get_the_title($post->ID) . '" alt="' . get_the_title($post->ID) . '" /></a>';
?>
<?php endif; ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2><br/>
<h3><?php the_author_posts_link(); ?> <span class="date">| <?php the_time('F d, Y') ?> |</span> <?php comments_popup_link('Post Comment', '1 Comment »', '% Comments »'); ?>
<fb:like href="<?php the_permalink() ?>" layout="button_count" width="100" font="lucida grande"></fb:like>
</h3>
<?php the_excerpt(); ?>
<p class="postreadmore"><a href="<?php the_permalink() ?>" class="arrow"> Read More </a></p>
</li>
<?php endwhile; ?>
</ul>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
<?php if(function_exists('wp_paginate')) {
wp_paginate();
} ?>
<?php } ?>
<?php endif; ?>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用
query_posts()
,请确保包含paged
参数。以下内容应该有所帮助: http://ivanasetiawan.com/wp-pagination -停留在同一页面/If you are using
query_posts()
, make sure you are including thepaged
parameter. The following should help: http://ivanasetiawan.com/wp-pagination-stays-on-the-same-page/