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>

This website may contain fan art inspired by existing characters from films, TV shows, or games. I don't own any rights to those characters — any copyright owner wishing to have a fan art removed can contact me here. This is a personal portfolio and store. It uses only the essential cookies needed for the site, cart, and account to work — no analytics, no tracking, no advertising.