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.
Page1: tag1, tag5, tag4
Page2: tag1, tag2, tag3
Page3: tag2, tag5, tag4

result: page1, page2 , page3

How to realise that?

Filtering blog post by two independent tags

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



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



it works, thanks alot.


hey, peterp, how did you resolve your question?


@peterp please share your solution


You can use a filter operator:

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


Thank you I’m trying out