Filtering post by checkbox field

Hi. I have this code running and I like to filter the loop by a checkbox-field I’ve allready added to the “events”.

<?php foreach($events->sortBy('sortierdatum', 'desc') as $event): ?>
<div class="event">
		<p class="event__dat"><?= $event->datum()->text() ?></p>
		<div class="event__zeit">
			<?= $event->uhrzeit()->kirbytext() ?>
		</div>
		<div class="event__titel">
			<?= $event->veranstaltungstitel()->kirbytext() ?>
		</div>
		<div class="markdown">
			<?= $event->text()->kirbytext() ?>
		</div>
</div>
<?php endforeach ?>

So only events with the checkbox checked should be posted. I’m sure this is a dead simple thing but I didn’t find a hint. Can anyboy help me?

1 Like
$events = $events->filterBy('name_of_cb_field', true)->sortBy('sortierdatum', 'desc');

If true doesn’t work, use "1".

filterBy('aktuell', '1')

Yesssss! Thank you very much …

1 Like