我在模板上有以下查询,我在其中调用子页面显示:
<?php $parent = $post->ID; ?>
<?php query_posts(array('showposts' => 3, 'paged' => $page_num, 'post_parent' => $post- >ID, 'post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'ASC'));?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
它工作正常,但我真的需要opaginate结果,我尝试了很多插件来实现这一点但没有人工作,在最好的风景中,分页插件正确显示了我有多少页面,但当我点击第二页例如,它显示了相同的结果,网址更改为/ mysite / category / page / 2 /但它不会更改内容。
任何想法??
答案 0 :(得分:2)
你如何设置$ page_num?
您是否使用get_query_var()更新变量?如果没有,您可以使用类似的东西来设置变量:
$page_num = (get_query_var('paged')) ? get_query_var('paged') : 1;
看看: http://codex.wordpress.org/Pagination#Adding_the_.22paged.22_parameter_to_a_query
答案 1 :(得分:0)
感谢Codebrick,我的代码现在看起来像这样,并且有效!
<?php $parent = $post->ID; ?>
<?php $page_num = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php query_posts(array('paged' => $page_num, 'post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 3, 'paged' => $paged));?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
其余的就是你想要的:)。