Wordpress - Show link to the next and previos brother of the current page, and a link to the page parent
Must be placed after the_post()
Copy this code and paste it in your HTML
<?
if (!empty($post->post_parent)) { $pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_order=asc");
foreach ($pagelist as $pagina) {
$pagini[] += $pagina->ID;
}
}
$prevID = $pagini[$current-1];
$nextID = $pagini[$current+1];
?>
<div class="navigation">
<?php if (!empty($post->post_parent)) { ?> <div style="clear:both;"><a href="
<?php echo get_permalink
($post->post_parent);
?>"
title="
<?php echo get_the_title
($post->post_parent);
?>">
<?php echo get_the_title
($post->post_parent);
?></a></div>
<?php } if (!empty($prevID)) { ?> <div class="alignleft">
<a href="
<?php echo get_permalink
($prevID);
?>"
title="
<?php echo get_the_title
($prevID);
?>">«
<?php echo get_the_title
($prevID);
?></a>
</div>
<?php }
if (!empty($nextID)) { ?> <div class="alignright">
<a href="
<?php echo get_permalink
($nextID);
?>"
title="
<?php echo get_the_title
($nextID);
?>">
<?php echo get_the_title
($nextID);
?> »</a>
</div>
<?php } ?>
</div>
Report this snippet