Skip to content

andRelatedTo with a condition #15886

Answered by brandonkelly
shifuma asked this question in Q&A
Discussion options

You must be logged in to vote

Gotcha. The only current way to do that is by getting the IDs of the nested entries first, and then passing them to the Matrix field’s param on the parent entry query:

{% set nestedIds = craft.entries()
  .field('myMatrixField')
  .type(['type1Handle', 'type3Handle'])
  .ids() %}

{% set entries = craft.entries()
  .section('mySection')
  .myMatrixField(nestedIds)
  .all() %}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@shifuma
Comment options

@brandonkelly
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants