Prev/Next child navigation for current page modifications?
Question
i am using a code that was answered posted here and answered very well .
Prev/Next child navigation for current page? answered by user phife-dawz
the issue i am trying to run that inside a function by calling it inside a page template
<?php
if ( is_page(array('5145','7','8','25')) ) {
getPrevNext();
}
?>
and the function is placed inside the code snippet plugin
and it is this
function getPrevNext(){
$pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_order=asc");
$pages = array();
$pages = array();
foreach ($pagelist as $page) {
$pages[] += $page->ID;
}
$current = array_search($post->ID, $pages);
$prevID = $pages[$current-1];
$nextID = $pages[$current+1];
echo '<div class="navigation">';
if (!empty($prevID)) {
echo '<div class="alignleft">';
echo '<a href="';
echo get_permalink($prevID);
echo '"';
echo 'title="';
echo get_the_title($prevID);
echo'">Previous</a>';
echo "</div>";
}
if (!empty($nextID)) {
echo '<div class="alignright">';
echo '<a href="';
echo get_permalink($nextID);
echo '"';
echo 'title="';
echo get_the_title($nextID);
echo'">Next</a>';
echo "</div>";
}
}
****
the output i get is only showed with Next link , but that also shows only a specific next page regarding the page we are viewing
0
2 years
2020-12-24T10:10:23-05:00
2020-12-24T10:10:23-05:00 0 Answers
3 views
0
Leave an answer