我的分页不能与WP_Query()
一起使用。WP_Query中分页不起作用()
我一共有三个职位。页面1正确显示了所有三个帖子。但第2页显示了相同的三个帖子。实际上,不应该有第2页,因为第1页已经显示了所有三个帖子。
什么可能是错的?
。
循环中index.php
<?php
$query = new WP_Query('cat=1');
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
the_title();
endwhile;
endif;
?>
<?php my_pagination(); ?>
。
。
分页中functions.php
if (! function_exists('my_pagination')) :
function my_pagination() {
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'prev_next' => True,
'total' => $wp_query->max_num_pages
));
}
见我的回答你的其他信息[这里](http://stackoverflow.com/a/25589440/1908141)。这应该解决你所有的问题 – 2014-08-31 06:19:59