I have a products page on which I'm filtering with Sprig. There are some categories in the form of checkboxes. These categories have some subcategories. The categories are a structured section with nested categories.


  • Category 1
    • Subcategory a
    • Subcategory b
  • Category 2
    • Subcategory c
    • Subcategory d

What I currently got working is to show the level 2 categories filters based on the chosen main category. What does not work is doing the same but for 2 main categories at the same time.

When the user clicks Category 1 I want to a query to return Subcategory a and Subcategory b.

When the user clicks Category 1 AND Category 2 I want to a query to return Subcategory a, Subcategory b, Subcategory c and Subcategory d.

My query:

{% set typeOptions = craft.entries()
 .orderBy('title ASC')

The reason why I am using join is because descendantOf does not accept an array and it seems it also does not accept comma separated string. It does accept a non comma separated string. I'm guessing it converts it to an INT internally.

How do I fix this?

  • Can you let us know what subcategories is defined as in your codebase? Seeing how you defined it will help us know what data type it is and whether that's a factor
    – cherrykoda
    Commented Sep 22, 2023 at 18:25
  • It's all just a big structured section. And I'm trying to get the title field.
    – Matthias
    Commented Sep 27, 2023 at 9:22
  • Right, but how are you calling it? Depending how it could be an object, an ID value...
    – cherrykoda
    Commented Oct 1, 2023 at 14:53


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.