Wordpress | Custom Previous/Next posts

<?php
$pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_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];

if (!empty($prevID) || !empty($nextID)) { ?>
<div class="navigation-wrapper">
    <div class="navigation">
        <?php if (!empty($prevID)) { ?>
        <div class="cell cell-previous">
            <a href="<?php echo get_permalink($prevID); ?>" title="<?php echo get_the_title($prevID); ?>">
                Précédent<br>
                <strong><?php echo get_the_title($prevID); ?></strong>
            </a>
        </div>
        <?php } ?>
        <?php if (!empty($nextID)) { ?>
        <div class="cell cell-next">
            <a href="<?php echo get_permalink($nextID); ?>" title="<?php echo get_the_title($nextID); ?>">
                Suivant<br>
                <strong><?php echo get_the_title($nextID); ?></strong>
            </a>
        </div>
        <?php } ?>
    </div>
</div>
My website may contain fan art inspired by existing characters from movies or tv shows, I dont own any rights. Any copyright owner willing to remove those fan arts can contact me here. This is a personal portfolio, the sole use of cookies are for analysing my traffic through Google Analytics, if you're ok with that please accept this terms by closing this disclaimer.