I want to get list of entries in my section video related to my current entry

{% for video in craft.entries.section('videos').limit('3').relatedTo({targetElement: entry.title, field: 'talents'}) %}

problem is entry.title is text, but talents is array.


The relatedTo parameter accepts an element, the ID of an element, an array if element ids or an object of type EntryQuery.

All you need to do is to pass the ID rather than the title

targetElement: entry.id

Furthermore if you use Craft 3 you might want to execute your query by calling .all() talents doesn't contain an array. It contains an object of type EntryQuery that can be executed in order to get an array of elements


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.