1

I'm struggling to get a and entry query to work - it seems to be stuck on or.

Query is {% set blogQ = blogQ.blogTags(['and', blogTag|join(",")]) %} where blogTag is [2291,2290] in this case. This would translate to {% set blogQ = blogQ.blogTags(['and',2291,2290]) %}

In this instance I get 0 results.

If I change to use {% set blogQ = blogQ.blogTags(blogTag) %} then I'll get entries that have the tag id of 2291 OR 2290

1 Answer 1

1

The problem here is join(",") as it is returning a string of your values, something like "123, 456" instead of a comma separated list of int as you expect.

Try this:

{# Create an array starting in 'and` #}
{% set relatedTags = ['and'] %}

{# Merge your ids in your relatedTags array #}
{% set blogQ = blogQ.blogTags(relatedTags | merge(blogTag)) %}

See documentation for the merge filter.

2
  • 1
    Thank you! Makes sense now. So the query I was trying would actually look like: {% set blogQ = blogQ.blogTags(['and',"2291,2290"]) %}?
    – Jaytrix
    Jun 1 at 9:03
  • Yes! That's it :)
    – Oli
    Jun 2 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.