1<?php
2 $all_posts = new WP_Query(array(
3 'orderby' => 'menu_order',
4 'order' => 'ASC',
5 'posts_per_page' => -1
6 ));
7
8 foreach($all_posts->posts as $key => $value) {
9 if($value->ID == $post->ID){
10 $nextID = $all_posts->posts[$key + 1]->ID;
11 $prevID = $all_posts->posts[$key - 1]->ID;
12 break;
13 }
14 }
15?>
16<?php if($prevID): ?>
17 <span class="prev">
18 <a href="<?= get_the_permalink($prevID) ?>" rel="prev"><?= get_the_title($prevID) ?></a>
19 </span>
20<?php endif; ?>
21<?php if($nextID): ?>
22 <span class="next">
23 <a href="<?= get_the_permalink($nextID) ?>" rel="next"><?= get_the_title($nextID) ?></a>
24 </span>
25<?php endif; ?>