Fetching articles minus the ones with a specific tag

Hi everyone ,

Is there a quick way to fetch all articles from a blog part in kirby MINUS the ones with a specific tag ?

Thanks in advance

You can use filterBy() with an operator:

$filtered = page('blog')->children()->visible()->filterBy('tags', '!=', 'some_tag');

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

thanks a lot !

It worked great, just adding the separator for tags at the end, in case anyone is looking for this…

$filtered = page('blog')->children()->visible()->filterBy('tags', '!=', 'some_tag', ',');
1 Like