K
K
Konstantin Teploukhov2018-02-27 00:54:11
WordPress
Konstantin Teploukhov, 2018-02-27 00:54:11

Single parent page pagination?

Good afternoon .
I have a page for example

nature drawing
and it is the parent of the pages Lesson-1 , Lesson-2 , Lesson-3 etc . How can I make pagination for these pages?
For posts if I'm not mistaken something like this
<?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 );
 ?>

But here's how for the pages and did not figure it out.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Teploukhov, 2018-02-27
@blood-moon

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 } ?>

Already good . (since that was needed too)
But here's how to make links to the trail. I did not find the article in order of adding (pagination - if I'm not mistaken in the name).
Is there really no crutch for child pages that would do something like this for articles?
<?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 );
 ?>

-------------------------------------------------- ------------------------
All the guys, googled.
Here is the code, maybe someone else will need it
<?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 -->

P
po5epT, 2018-02-27
@po5epT

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'
) );

and then you already output this array as a list as you like.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question