I have a query to select only child pages of the ‘shop’, but I also want to be able to select child pages of the ‘ingredients’ page. I kind of need an “and” in the query.
fields:
linked_product:
type: pages
query: page('shop').children
I have a query to select only child pages of the ‘shop’, but I also want to be able to select child pages of the ‘ingredients’ page. I kind of need an “and” in the query.
fields:
linked_product:
type: pages
query: page('shop').children
A couple of options there. If those pages have unique templates you can pick up on that. You can also setup a collection that gets the pages you want then query the collection instead. These pages from the docs should help.
So your query will instead be something like
query: site.index.filterBy("template", "in", ["shoptemplate", "ingredientstemplate"])
If you want to use collections instead, you can learn more about those here:
query: pages(['shop', 'ingredients'])->children()
should also work.
Hmm, I’ve tried
query: pages(['shop', 'ingredients'])->children()
but get the following error popup
ChatGTP suggests this
query: page('shop').children.add(page('ingredients').children)
It appears to work, but I’d appreciate your thoughts on it
Hm, maybe the array does not work in query language after all, only in PHP…
With using dots instead maybe?
query: pages([‘shop’, ‘ingredients’]).children
Oh my…
Afraid this doesn’t work
query: pages([‘shop’, ‘ingredients’]).children
But this does work
query: page('shop').children.add(page('ingredients').children)
and so does your original solution
query: site.index.filterBy("template", "in", ["shoptemplate", "ingredientstemplate"])
Thanks