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 2 months ago · 2 replies · 321 views
2 months 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
2 months 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
2 months 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 Roger Parkinson, 6 days ago
3 193 23 hours ago
Support · by gravinator, 2 days ago
2 115 1 day ago
Support · by Marcel, 1 week ago
4 201 5 days ago
Support · by cvgrenoble, 1 week ago
3 182 1 week ago
Support · by Paul Hodges, 1 month ago
19 610 3 weeks ago