Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Page collection with tagA OR tagB or tagC etc

Solved by pamtbaau View solution

Started by stuart young 4 weeks ago · 2 replies · 231 views
4 weeks ago

This below frontmatter works to collect all pages tagged hk but I want to have a collection with multiple asian countries based on the individual post tags. If I add tags the page collection is empty because the page collection assumes AND between them, is there a way have a page collection that uses OR?

YAML
---
title: Hong Kong` 
content:
  items:
    '@taxonomy.tag': hk
  order:
    by: date
    dir: desc  
  limit: 12
  pagination: true
visible: true
access: 
  site.login: true
---
last edited 07/21/26 by pamtbaau
3 weeks ago Solution

@lordkelvin88, Please consider the reader and format code/yaml correctly using tripple backticks (```).

After editing your post, you might take a look at Complex Collections

You can also provide multiple complex collection definitions and the resulting collection will be the sum of all the pages found from each of the collection definitions. For example:

YAML
content:
  items:
    - '@self.children'
    - '@taxonomy':
         category: [blog, featured]
👍 1
last edited 07/21/26 by pamtbaau
3 weeks ago

Thanks, I had looked at complex collections but not closely enough, this got me to this which worked as I wanted

YAML
---
title:  Asia
content:
    items:
      - '@taxonomy.tag': hk
      - '@taxonomy.tag': jp
      - '@taxonomy.tag': th
    order:
        by: date
        dir: desc
    limit: 12
    pagination: true
visible: true
access:
    site.login: true
---

Suggested topics

Topic Participants Replies Views Activity
Support · by Anna, 1 week ago
4 327 8 hours ago
Support · by gtx, 2 weeks ago
4 331 1 week ago
Support · by Paul Hodges, 3 weeks ago
13 375 2 weeks ago
Support · by Anna, 4 weeks ago
9 433 2 weeks ago
Support · by TomW, 3 weeks ago
4 273 3 weeks ago