Skip to content

Excluding certain links from the menu #284

Answered by taufik-nurrohman
prtst33 asked this question in Q&A
Discussion options

You must be logged in to vote

You can add custom property to a page to tell the loop that certain item need to be excluded. This is common example:

---
title: Exclude Me
description: Exclude this page from menu.
skip: true
...

Lorem ipsum dolor sit amet.

Then in the navigation loop (the second line):

<?php foreach ($links as $link): ?>
  <?php if ($link->skip) continue; ?>
  <li>
    <a href="<?= $link->url; ?>">
      <?= $link->title; ?>
    </a>
  </li>
<?php endforeach; ?>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by prtst33
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
x.list List extension. x.page Page extension.
2 participants