Let's say that I have an Assets field on a single page where someone can add a bunch of images to a "gallery" on that page. Is there a way to perform a query and return the entries from a channel where these images are used as well?

Ideally, I'm trying to get the URL's to all of the listing entries where any of these images are also used, but without the admin explicitly relating them to those entries on the single page. There's no explicit relationship between them, other than the same images were used on both the single and channel entry.

1 Answer 1


You can use relatedTo for that:

{% set entries = craft.entries.section('mySection').relatedTo(myAsset) %}


{% set entries = craft.entries({ section: 'mySection', relatedTo: myAsset }) %}

Check out the documentation on relationships.

  • Thanks! Didn't realize that relatedTo would work without explicitly relating items.
    – jpea
    Sep 11, 2014 at 19:37
  • relatedTo is one of those magic ingredients that makes Craft look like something out of Harry Potter. :) Sep 11, 2014 at 21:23

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.