2016-09-06 113 views
0

我展示这样一个特定页面的子页面:编号分页页面WordPress的

$args = array(
'post_type'  => 'page', 
'post_parent' => $post->ID, 
'posts_per_page' => 3, 
'order'   => 'ASC', 
'post_status' => 'publish', 
'child_of' => $post->ID 
); 

$parent = new WP_Query($args); 

if ($parent->have_posts()) { ?> 

<?php while ($parent->have_posts()) : $parent->the_post(); ?> 


     <div class="bloc-page"> 
      <h1><?php the_title(); ?></h1> 
     </div> 


<?php endwhile; ?> 

我要的是一个编号的导航,只有三个职位的每个页面。但我不知道该怎么做,我尝试了很多解决方案,但没有成功。

感谢您的回复!

回答

0

刚过您while循环的末尾加上下面几行:

<?php 
$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')), 
    'total' => $parent->max_num_pages 
)); 
?> 

如需进一步帮助,请阅读WordPress官方文档分页here

0

你做了什么样的解决方案?你有没有尝试wp_reset_postdata();?