In Craft 5, we now have a few Entry types with Matrix fields that can nest several other Entry types, or none. I'm struggling to work out a way to limit the returned results based on the content of these fields.

For instance, we have an Entry type called Visit. This has a Matrix field called Activity, which can nest any of these three Entry types: Restaurant, Event, Location.

I want to be able to get all of the Activity entries that contain at least one nested Restaurant entry.

I expected to be able to do something like:

activityEntries(relatedToEntries: {type: "restaurant"}){

It seems that Matrix fields don't count as relations (?), so is there some other way to approach this?

I'd wondered if you could effectively go in the other direction (query all Restaurant entries, then filter based on being related to Activity), but again haven't had any luck.


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.