# Exclude if template is equal to

**URL:** <https://forum.getkirby.com/t/exclude-if-template-is-equal-to/7771>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 20, 2017, 10:01pm UTC](https://forum.getkirby.com/t/exclude-if-template-is-equal-to/7771 "2017-06-20T22:01:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbarclay](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bbarclay](https://forum.getkirby.com/u/bbarclay)\
**Post date:** [June 20, 2017, 10:01pm UTC](https://forum.getkirby.com/t/exclude-if-template-is-equal-to/7771/1 "2017-06-20T22:01:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![twirx](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@twirx](https://forum.getkirby.com/u/twirx)\
**Post date:** [June 20, 2017, 10:11pm UTC](https://forum.getkirby.com/t/exclude-if-template-is-equal-to/7771/2 "2017-06-20T22:11:50Z")

</div>

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

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

```

Or even shorter:

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

```

---

<div class="post-metadata">

**Author:** ![bbarclay](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bbarclay](https://forum.getkirby.com/u/bbarclay)\
**Post date:** [June 20, 2017, 10:24pm UTC](https://forum.getkirby.com/t/exclude-if-template-is-equal-to/7771/3 "2017-06-20T22:24:01Z")

</div>

Thank you so much 🙂

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:35pm UTC](https://forum.getkirby.com/t/exclude-if-template-is-equal-to/7771/4 "2025-02-06T17:35:29Z")

</div>


