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 days ago · 2 replies · 65 views
2 days 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 days 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 days 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 TomW, 2 hours ago
1 11 2 hours ago
Support · by Anna, 3 days ago
7 89 5 hours ago
Support · by Anna, 3 days ago
5 98 5 hours ago
Support · by Anna, 5 hours ago
0 8 5 hours ago
Support · by BenLaKnet, 2 weeks ago
3 215 3 days ago