I am using this wonderful bit of code created by jackreichert.
This in the functions.php
file.
function siblings($link) {
global $post;
$siblings = get_pages('child_of='.$post->post_parent.'&parent='.$post->post_parent);
foreach ($siblings as $key=>$sibling){
if ($post->ID == $sibling->ID){
$ID = $key;
}
}
$closest = array('before'=>get_permalink($siblings[$ID-1]->ID),'after'=>get_permalink($siblings[$ID+1]->ID));
if ($link == 'before' || $link == 'after') {
echo $closest[$link];
}
else
{
return $closest;
}
}
and this on the template page
<?php siblings('before'); ?>
and
<?php siblings('after'); ?>
It works wonderfully, but to the echo I would like to be able to add the name of the link as well. How could this be done?
Change this line:
To: