Filtering my sub navigation menu

Hi,

I watched this video https://www.youtube.com/watch?v=bmz6NYUNWPk and I must say that it help me learn how to create the navigation menu. However, I would like to be able to filter the submenu to display certain items. This is the code:

<nav class="desktop-navigation">
      <ul>
        <li>
          <a href="#">Home</a>
          <ul class="dropdown">
            <?php foreach ($site->children() as $item): ?>
              <li><a href="<?= $item->url() ?>"><?= $item->title() ?></a></li>
            <?php endforeach ?>
          </ul>
        </li>
        <?php foreach ($site->children()->listed() as $item): ?>
          <li><a href="<?= $item->url() ?>"><?= $item->title() ?></a></li>
        <?php endforeach ?>
      </ul>
    </nav>
  </div>

The sub menu displays folders that exist inside the content folder such as kontakt, error, about, images, etc. which should not be showing in the sub menu. Grateful for your support.

I’ve put put it like this in attempt to isolate the about folder:

<ul class="dropdown">
            <?php if ($item->id() != 'about'): ?>
    <li><a href="<?= $item->url() ?>"><?= $item->title() ?></a></li>
  <?php endif ?>

but the debugger gave the following error message: Undefined variable $item

I was able to figure it out :slight_smile: and thought I would share this link in case someone stumbles across this topic $pages->not() | Kirby CMS (getkirby.com)