Show "Previous" when there is no "next"

   <?php if($next = $page->nextVisible()): ?>
      <h2><a class="next" href="<?php echo $next->url() ?>">Next Project</a></h2>
    <?php endif ?>

    <?php 
    if ($prev = $page->nextVisible()): ?>
    <h2><a class="prev" href="<?php echo $prev->url() ?>">Previous Project</a></h2>
  <?php endif ?>

Question: how can i make it possible that “Previous Project” is only visible when there is no “Next Project” visible?

If Next is false show Previous. Sorry be kind i’m a bit green :slight_smile:

Maybe you can use this:

if ( $page->hasNext() ) {
  echo 'Has next';
}
<?php 
    if (!$page->hasNextVisible() && $prev = $page->prevVisible()): ?>
    <h2><a class="prev" href="<?php echo $prev->url() ?>">Previous Project</a></h2>
  <?php endif ?>
2 Likes

Thanks a lot. Works fine