[英]wp pagenavi for pagination ,too many pages for number of posts
is it possible to have wp-pagenavi set up so that the number of numbers in the pagination is relative to the number of posts. 是否可以设置wp-pagenavi,以便分页中的数字数量与帖子数相关。
At the moment , even there is only 3 or 4 posts in a category it still gives me the option to go to lots of old pages , which obviously just show up empty. 目前,即使一个类别中只有3或4个帖子,它仍然让我可以选择转到许多旧页面,这些页面显然只是空白。
Here is an example, there are only 4 posts in this category... http://limerickfc.hailstormcommerce.com/cms/?page_id=2466 这是一个示例,该类别中只有4个帖子... http://limerickfc.hailstormcommerce.com/cms/?page_id=2466
Here is the code Im using for the loop. 这是Im用于循环的代码。
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("posts_per_page=12&paged=$paged");
$archive_query = new WP_Query('cat=14&showposts=12&paged=' . $paged);
...
if (have_posts()) :
while ($archive_query->have_posts()) : $archive_query->the_post();
...do stuff
?>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php wp_reset_query(); ?>
<?php endif; ?>
That's not how I would use WP-Pagenavi, you don't need to include the pagination part of the custom query, I think that is the source of your problem. 那不是我使用WP-Pagenavi的方式,您不需要在自定义查询中包括分页部分,我认为这就是问题的根源。
$archive_query = new WP_Query('cat=14&showposts=12');
Incidentally, showposts has been deprecated in favour or posts_per_page
. 顺便说一句,showposts已被赞成或posts_per_page
。
My solution... 我的解决方案...
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
?>
<?php query_posts('cat=14&posts_per_page=3'."&paged=$paged"); ?>
<?php
$id = get_the_ID();
$count = 0;
if (have_posts()) : ?>
<?php while ( have_posts() ) : the_post();
........
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php wp_reset_query();?>
<?php endif; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.