Next Previous siblings child pages
I tried this piece of code : https://wordpress.stackexchange.com/a/54474/80921 because I couldn't figure out how to get the next and the previous post. But this code won't work now and I'm not able to comment.
The error I get is Undefined offset: -1 when looking for the ID. Here is the full code found on the related page. Thanks for any help !
$pagelist = get_pages(child_of=.$post-post_parent.parent=.$post-post_parent.sort_column=menu_ordersort_order=asc);
$pages = array();
foreach ($pagelist as $page) {
$pages[] += $page-ID;
}
$current = array_search($post-ID, $pages);
$prevID = $pages[$current-1];
$nextID = $pages[$current+1];
?
div class=navigation
?php if (!empty($prevID)) { ?
div class=previous
a href=?php echo get_permalink($prevID); ? title=?php echo get_the_title($prevID); ?Previous/a
/div
?php }
if (!empty($nextID)) { ?
div class=Next
a href=?php echo get_permalink($nextID); ? title=?php echo get_the_title($nextID); ?Next/a
/div
?php } ?
/div