Answers.Body: <p>I'm not sure where you're getting the id's from but you will need to pass an array into <code>craft.entries.id</code> so try:</p>
  
  <pre><code>{% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
  
  {% set navsubidarray = [] %}
  
  {% for navsubid in navsubids %}
    {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
  {% endfor %}
  
  {% for entry in craft.entries.id( navsubidarray ) %}
    {{ entry.title }}&lt;br&gt;
  {% endfor %}
  </code></pre>
  
  <p>When you used <code>{% set navsubidarray = navsubidarray|join(', ') %}</code> you were creating a string of the values in the array.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-16T14:54:01.733Z
Answers.LastActivityDate: 2016-05-16T14:54:01.733Z
Answers.UserDisplayName: Luke Pearce
Answers.Body: <p>Luke's answer above is correct, you might as well just use the array directly.</p>
  
  <p>But technically you can use a joined string as well, it's just your syntax is wrong - you just call the variable directly:</p>
  
  <pre><code>{% for entry in craft.entries.id(navsubidarray) %}
        {{ entry.title }}&lt;br&gt;
  {% endfor %}
  </code></pre>
  
  <p>I just add this here in case it's ever useful to someone who for whatever reason wants to use a string of IDs in another scenario.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-17T00:32:24.500Z
Answers.LastActivityDate: 2016-05-17T00:32:24.500Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>I want to show entries according to an array.</p>
  
  <p>This is my code:</p>
  
  <pre><code>            {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
              {% set navsubidarray = [] %}
  
              {% for navsubid in navsubids %}
                      {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
              {% endfor %}
  
              {% set navsubidarray = navsubidarray|join(', ') %}
  
              {{ navsubidarray }}&lt;br&gt;
  
              {% for entry in craft.entries.id('{{ navsubidarray }}') %}
                  {{ entry.title }}&lt;br&gt;
              {% endfor %}
  </code></pre>
  
  <p>The variable gives back that what I need <code>(18, 17, 19, 4, 20, 21, 22, 23)</code> but the for entry loop isn't returning anything.</p>
  
Tags: <variable>
Title: Using a variable with array of ElementIds to use in craft.entries.id
ThreadText: # Using a variable with array of ElementIds to use in craft.entries.id
  
  (Asked by: username_0 on 2016-05-16)
  
  I want to show entries according to an array.
  
  This is my code:
  
  ```
              {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
              {% set navsubidarray = [] %}
  
              {% for navsubid in navsubids %}
                      {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
              {% endfor %}
  
              {% set navsubidarray = navsubidarray|join(', ') %}
  
              {{ navsubidarray }}<br>
  
              {% for entry in craft.entries.id('{{ navsubidarray }}') %}
                  {{ entry.title }}<br>
              {% endfor %}
  
  ```
  
  The variable gives back that what I need `(18, 17, 19, 4, 20, 21, 22, 23)` but the for entry loop isn't returning anything.
  
  **Tags:** variable
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-05-16. Score: 3 | Accepted answer
  
  I'm not sure where you're getting the id's from but you will need to pass an array into `craft.entries.id` so try:
  
  ```
  {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
  
  {% set navsubidarray = [] %}
  
  {% for navsubid in navsubids %}
    {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
  {% endfor %}
  
  {% for entry in craft.entries.id( navsubidarray ) %}
    {{ entry.title }}<br>
  {% endfor %}
  
  ```
  
  When you used `{% set navsubidarray = navsubidarray|join(', ') %}` you were creating a string of the values in the array.
  
  
  ---
  
  ### Answer by username_2 on 2016-05-17. Score: 3
  
  username_1's answer above is correct, you might as well just use the array directly.
  
  But technically you can use a joined string as well, it's just your syntax is wrong - you just call the variable directly:
  
  ```
  {% for entry in craft.entries.id(navsubidarray) %}
        {{ entry.title }}<br>
  {% endfor %}
  
  ```
  
  I just add this here in case it's ever useful to someone who for whatever reason wants to use a string of IDs in another scenario.
  
  
  ---
  
  