Exclude if template is equal to

In the homepage menu I want to exclude subpages from showing in a dropdown menu if they are set to a certain template.

How can I do this. the name of the template is anchor.

So show all the other children in the menu unless their template == anchor.

Thanks

You can use the filter-method on the collection of pages for the submenu:

$menutItems = $pages->filter(function($page) {
    return $page->template() !== 'anchor';
});

Or even shorter:

$menuItems = $pages->filterBy('template', '!=', 'anchor');

Thank you so much :slight_smile: