Relationship between channels/entries I need some help. Really struggle understanding how to build relationships between channels/entries.

Context/Want:
I have two separate channels:
1. "Plant catalogue"
2. "Plant care"
I want to re-use the entries from "Plant catalogue" across the whole website wherever I need it accesing speicifc fields.

What I have:
"Plant care" has an entries field type to help build the relationship with "Plant catalogue": field name: "plantEntity"
"Plant catalogue" has an asset field that include a photo of the plant. fiel name: "plantPhoto"

My code so far:

{% set plantcareListing = craft.entries().section('plantCare').limit(null)%}
{% set entries = plantcareListing.all() %}

{% for entry in entries %}
  {% for image in entry.plantEntity %} {# how do I access the asset field "plantPhoto" here? :( #}
    &lt;img src="{{ image.getUrl() }}" alt="{{ image.title }}"&gt;
  {% endfor %}

  {{ entry.title }}
{% endfor %}


I would appreciate your advice. Thank you!
It’s important to understand that using relations fields in the template works similar to using craft.entries. They return a element query object, for example entry.plantEntity in your entries loop. And you need to call the all() method on them to query for the elements. The same applies to querying for the asset elements in your inner entries loop.

{% set plantCares = craft.entries
    .section('plantCare')
    .all() %}

{% for plantCare in plantCares %}
    {% for plantEntity in plantCare.plantEntity.all() %}
        {% for plantPhoto in plantEntity.plantPhoto.all() %}
            &lt;img src="{{ plantPhoto.getUrl() }}" alt="{{ plantPhoto.title }}"&gt;
        {% endfor %}

        {{ plantEntity.title }}
    {% endfor %}
{% endfor %}


You should generally avoid querying in a loop though, and use eager-loading instead.

{% set plantCares = craft.entries
    .section('plantCare')
    .with([
        'plantEntity',
        'plantEntity.plantPhoto'
    ])
    .all() %}

{% for plantCare in plantCares %}
    {% for plantEntity in plantCare.plantEntity %}
        {% for plantPhoto in plantEntity.plantPhoto %}
            &lt;img src="{{ plantPhoto.getUrl() }}" alt="{{ plantPhoto.title }}"&gt;
        {% endfor %}

        {{ plantEntity.title }}
    {% endfor %}
{% endfor %}


If you’ve got many plantCare entries consider paginating through them.