Show pages by filtering multiple tags?

Hi all,
how to display pages with multiple tags.

foreach(page('sites')->children()->visible()->filterBy('tags', 'tag1,tag2,tag4' ',')->limit(3) as $project):

The result shoule be: 3 items, with tags from different pages.
example:
Page1: tag1, tag5, tag4
Page2: tag1, tag2, tag3
Page3: tag2, tag5, tag4

result: page1, page2 , page3

How to realise that?

1 Like

You could use a custom filter like this one for multiple file extensions:

1 Like

Hi,

i dont’t want to filter files. I want to show different page items via tags.

I know, it was just an example that you can adapt to filter pages instead of files

1 Like

Hi,

it works, thanks alot.

hey, peterp, how did you resolve your question?

1 Like

up!
@peterp please share your solution

You can use a filter operator:

$filterTags = ['tag1', 'tag2', 'tag3'];
$filteredCollection = $pages->filterBy('tags', 'in', $filterTags);

https://getkirby.com/docs/cheatsheet/pages/filter-by#available-filter-methods

1 Like

Thank you I’m trying out