How to exclude menu item link

Just can’t seem to find the right answer, although it shouldn’t be difficult.

I want to exclude a page from the usual main menu, how can I exclude a page, without making the page invisible. I want to use a loose call-to-action button with a link to that page, that’s what I already managed to do.

I think something like $pages->not(page('pagetoexclude')) could work.

1 Like

Thanks @distantnative, this works!

For others, first the menu started with this regular part

<?php foreach($pages->visible() as $p): ?>

I’ve changed it to this :smile:

<?php foreach($pages->visible()->not(page('aanmelden')) as $p): ?>

and now it excludes the “aanmelden” page

1 Like

I try to exclude several pages at once, like this:

<?php foreach($pages->visible()->not(page('about', 'contact')) as $p): ?>

This only excludes the first item. Am I doing something wrong?
(Reason for doing this: I want to use a custom menu that only contains these items at another place.)

The page helper only takes one argument and returns a single page. The following should work:

<?php foreach($pages->visible()->not('about', 'contact') as $p): ?>
1 Like

Purrrrfect! Thanks a lot.