Filter by toggle? - Kirby 3

Is there an example of how to filter by a toggle input?

my blueprint is like this:
label: Toggle
width: 1/3
type: toggle
text: Include in overview?

the posts should be filtered

<section class="masonry">
  <?php foreach ($pages->template('post') as $item) : ?>
    <figure class="masonry-item">
      <a href="<?= $item->url() ?>">
        <?= $item->images()->sortBy('sort', 'asc')->first()->resize(400) ?>
  <?php endforeach ?>

This should work:

<?php foreach ($pages->template('post')->filterBy('toggle', true) as $item) : ?>

A toggle field’s content will either be true or false.

1 Like

that worked perfectly, thanks! seems quite obvious now