Countingthe amount of pages with a multiselect field selected

Happy holidays to everyone… just a quick question for anybody once you’re back at work :slight_smile:

I am trying to count() the amount of pages with a multiselect field.

In this case, the multiselct field is artworkType.

$siblings = $page->siblings()->listed();
$types    = $siblings->pluck('artworkType', ',', true);
foreach($page->artworkType()->split() as $artworkType): ?>

 There are <?= $siblings->filterBy('types', $artworkType, ',')->count() ?> <?= $artworkType ?> in the database.

<?php endforeach ?>
<?php endif ?>

I am only getting 0 as the count number. :frowning:

What for this line?

Not sure but I guess, should be artworkType instead of types, like that:

->filterBy('artworkType', $artworkType, ',')

Thanks a lot @ahmetbora, that solved it :slight_smile: