Answer the question
In order to leave comments, you need to log in
Single parent page pagination?
Good afternoon .
I have a page for example
nature drawingand it is the parent of the pages Lesson-1 , Lesson-2 , Lesson-3 etc . How can I make pagination for these pages?
<?php
$prev = get_previous_post_link( '%link', 'Прошлая глава', true );
echo str_replace( '<a ', '<a class="left-page arrow-page" ', $prev );
$next = get_next_post_link( '%link', 'Следующая глава', true );
echo str_replace( '<a ', '<a class="right-page arrow-page" ', $next );
?>
Answer the question
In order to leave comments, you need to log in
Found how to make a list of child pages on the main (parent) page
<?php
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
<?php
$prev = get_previous_post_link( '%link', 'Прошлая глава', true );
echo str_replace( '<a ', '<a class="left-page arrow-page" ', $prev );
$next = get_next_post_link( '%link', 'Следующая глава', true );
echo str_replace( '<a ', '<a class="right-page arrow-page" ', $next );
?>
<?php
$pagelist = get_pages('sort_column=menu_order&sort_order=asc');
$pages = array();
foreach ($pagelist as $page) {
$pages[] += $page->ID;
}
$current = array_search(get_the_ID(), $pages);
$prevID = $pages[$current-1];
$nextID = $pages[$current+1];
?>
<div class="navigation">
<?php if (!empty($prevID)) { ?>
<div class="alignleft">
<a href="<?php echo get_permalink($prevID); ?>"
title="<?php echo get_the_title($prevID); ?>">Previous</a>
</div>
<?php }
if (!empty($nextID)) { ?>
<div class="alignright">
<a href="<?php echo get_permalink($nextID); ?>"
title="<?php echo get_the_title($nextID); ?>">Next</a>
</div>
<?php } ?>
</div><!-- .navigation -->
There is no similar function for pages, as far as I know, so you can do this:
$childrens = get_children( array(
'post_parent' => id страницы родителя,
'post_type' => 'page',
'numberposts' => -1,
'post_status' => 'publish'
) );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question