Hiding Menu item

Hi Kirby and Kirbynettes, just getting my feet wet with Kirby, looks awesome and really enjoying the simplicity. I´ve been looking through a couple of posts, but could not find the right answer. Please do not judge, since I am still learning php.
I have meen using the plain template, since I am building a custom Page.

I want to hide a page in my main menu:

    <ul id="mobile_show" class="nav__menu">     

  <?php foreach ($site->children() as $item) :?>  
     <li>  <a href="<?= $item->url() ?>"><?= $item->menu() ?> </a> </li>
  <?php endforeach  ; ?>      

    </ul>

Could someone please point me into the right direction? I am using the current version. Thank you very much in advance!

Hey, welcome to the forum :wave: !

I guess you mean you want to skip a page in the loop? You can use not() to exclude pages from the collection, e.g.

$menuPages = $site->children()->not('somepage');

Or you can filter by the status of pages and a lot more. So it really depends on what your are trying to achieve here.

hi and thank you so much for your reply! Yes, I want to exclude 2 Pages from the loop, since these are in the footer with a custom menu.

Does the $menu variable have to be called before the loop? Tried this, but this does not work:

    <?php $menuPages = $site->children()->not('sample page one', 'sample page two');  ; ?>

  <?php foreach ($site->children() as $item) :?>
     <li>  <a href="<?= $item->url() ?>"><?= $item->menu() ?> </a> </li>
  <?php endforeach  ; ?>   

Thank you very much!

You now have to use your variable in the loop

 <?php foreach ($menuPages as $item) :?>
     <li>  <a href="<?= $item->url() ?>"><?= $item->menu() ?> </a> </li>
  <?php endforeach  ; ?>  

Otherwise the defined variable has no effect-

Of course! Sorry, that question was pretty stupid :see_no_evil:
Thanks for the fast help!