Blog Single

17 Jun

WordPress chield Pages pagination with counter in parent page

<div class=”container”>
<?php

$ids = array();
$pages = get_pages(“child_of=”.$post->ID);
if ($pages) {
foreach ($pages as $page) {
$ids[] = $page->ID;
}
}
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$args = array(
“paged” => $paged,
“post__in” => $ids,
“posts_per_page” =>1,
“post_type” => “page”
);
query_posts($args);
$count = count($pages);
echo $paged;  echo “/”; echo $count-=$paged;
?>
<?php next_posts_link(‘Next Entries’) ?>

<?php $pageval=$paged-1; if($pageval==0){ echo ‘Previous Entries’; } else { previous_posts_link(‘Previous Entries’); } ?>
<?php

if (have_posts()) : while (have_posts()) : the_post();
?>
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
<?php endwhile; else: ?>
<h2>Oh No!!</h2>
<p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p>
<?php endif; ?>

<?php wp_reset_query(); ?>
</div>.

Related Posts