How to loop through multiple entries fields I'm creating a dynamic side navigation where pages can choose which sidebar it wants to use. This is selected by an entries field called 'sidebar' - called in line 2.
To create this I've made a structure called 'Sidebars' with an entry for each sidebar type.
Each Sidebars entry has an entries field in it which can select any number of pages.
I've got it fully working, but it's giving me deprecation errors.
Here's the working (but deprecated code on line 4):
(lines 5-12 figure out whether the path includes 'whats-on' or 'who-we-are' and adds them to the path to the entry if needed).
&lt;div&gt;
  {% set sidebarChoice = entry.sidebar.one() %}
  {% for rel in sidebarChoice %}
    {% for sidebarEntry in rel %}
      {% set myEntryQueryUrl = sidebarEntry.url %}
      {% if 'whats-on' in myEntryQueryUrl %}
        {% set myEntryQueryPath = '/whats-on/' %}
      {% elseif 'who-we-are' in myEntryQueryUrl %}
        {% set myEntryQueryPath = '/who-we-are/' %}
      {% else %}
        {% set myEntryQueryPath = '/' %}
      {% endif %}

      &lt;div&gt;
        &lt;h3&gt;{{ sidebarEntry.title }}&lt;/h3&gt;
        &lt;a href=&quot;{{ myEntryQueryPath }}{{ sidebarEntry.slug}}&quot;&gt;
        &lt;p class=&quot;smallcontentblocks-text&quot;&gt;{{ sidebarEntry.title }} text&lt;/p&gt;
        &lt;/a&gt;
      &lt;/div&gt;

    {% endfor %}
  {% endfor %}
&lt;/div&gt;
You don't mention what your related entries field handle is, but remember that calling any related element (entries/assets/categories/users/tags) will require a .all() (or .one() or .ids() or one of the other query-executing methods) unless the related elements are eager-loaded. With that in mind I can't see anywhere in your code where you're executing a call to fetch the related entries from sidebarChoice, and you also seem to have a redundant inner loop. With eager-loading it might look like this:
&lt;div&gt;
  {% set sidebarChoice = entry.sidebar.with(['sidebar.yourRelatedEntriesHandle']).one() %}
  {% for sidebarEntry in sidebarChoice.yourRelatedEntriesHandle %}
      {% set myEntryQueryUrl = sidebarEntry.url %}
      {% if 'whats-on' in myEntryQueryUrl %}
        {% set myEntryQueryPath = '/whats-on/' %}
      {% elseif 'who-we-are' in myEntryQueryUrl %}
        {% set myEntryQueryPath = '/who-we-are/' %}
      {% else %}
        {% set myEntryQueryPath = '/' %}
      {% endif %}

      &lt;div&gt;
        &lt;h3&gt;{{ sidebarEntry.title }}&lt;/h3&gt;
        &lt;a href=&quot;{{ myEntryQueryPath }}{{ sidebarEntry.slug}}&quot;&gt;
          &lt;p class=&quot;smallcontentblocks-text&quot;&gt;{{ sidebarEntry.title }} text&lt;/p&gt;
        &lt;/a&gt;
      &lt;/div&gt;
  {% endfor %}
&lt;/div&gt;