<p>See below for some twig code to get you started, I omitted the actual HTML output for the individual items to better keep the overview. </p>

<p>Whats happening is, you get all (or a reasonable big amount amount) of your entries, and start looping over them. </p>

<p>The first time, you open a div that will contain 6 items. Afterwards, each time the loop index can be divised by 6 (aka, 6 more items have been looped over) you close the container div &amp; open a new one. </p>

<p>Than finally after the last iteration, you close the container div again. </p>

<p>Making the 6 items hide or display you can do with Javascript. Let me know if you need extra pointers on that. </p>

<pre><code>{% for entry in craft.entries.section('alumni').order('RAND()')}
    {% if loop.first %}
        &lt;div class="container-for-6-items"&gt;
    {% endif %}

    {# Build item output here #}

    {% if loop.index is divisible by(6) %}
        &lt;/div&gt;
        &lt;div class="container-for-6-items"&gt;
    {% endif %}

    {% if loop.last %}
        &lt;/div&gt;
    {% endif %}
{% endfor %}
</code></pre>

<p>Info on <a href="https://twig.symfony.com/doc/2.x/tests/divisibleby.html" rel="nofollow noreferrer">divisible by</a></p>

CC BY-SA 3.0
2017-07-24T12:55:20.383Z
2017-07-24T12:55:20.383Z
mrsmn
<p>I want to get entries randomly every minutes like setTimeout in javascript. Like below If possible. </p>

<pre><code>            setTimeout({ {% for entry in craft.entries.section('alumni').order('RAND()').limit(6).find() %}
            &lt;a class="main-home-list-item" href="#"&gt;
                &lt;div class="main-home-list-item__body"&gt;
                    {% set asset = entry.profileImage.first() %} {% if asset | length %}
                    &lt;div class="img-container"&gt;
                        &lt;img src="{{asset.getUrl()}}" alt="{{asset.title}}" /&gt;
                    &lt;/div&gt;
                    {% else %}
                    &lt;div class="img-container"&gt;
                        &lt;img src="assets/avatar.png" /&gt;
                    &lt;/div&gt;
                    {% endif %}
                    &lt;h4&gt;
                                {{ entry.title }} {{ entry.lastName }}
                            &lt;/h4&gt;
                    &lt;p class="small"&gt;
                        {{entry.graduateYear}}
                    &lt;/p&gt;
                &lt;/div&gt;
            &lt;/a&gt;
            {% endfor %} }, 1000);
</code></pre>

CC BY-SA 3.0
2017-07-24T11:26:17.873Z
Twig is pre rendered on the server so I'm not sure what you're trying to accomplish here? Do you want to show a new randomly chosen entry each minute?
mrsmn
CC BY-SA 3.0
2017-07-24T11:36:46.620Z
I want to get random entries from craft CP. like randomly showing images every minutes 6 at a time and looping through the others.
Yonas Hailu
CC BY-SA 3.0
2017-07-24T12:04:39.180Z
You'll have to output the html for all of them beforehand, in the order you choose, and than use javascript on the frontend to do the switching every minute. I'm en route at the moment, i'll try and whip the above into a proper answer when I get back.
mrsmn
<entries><craft3>
get entries randomly every minutes?
# get entries randomly every minutes?

(Asked by: username_0 on 2017-07-24)

I want to get entries randomly every minutes like setTimeout in javascript. Like below If possible. 
            setTimeout({ {% for entry in craft.entries.section('alumni').order('RAND()').limit(6).find() %}
            
                
                    {% set asset = entry.profileImage.first() %} {% if asset | length %}
                    
                        
                    
                    {% else %}
                    
                        
                    
                    {% endif %}
                    
                                {{ entry.title }} {{ entry.lastName }}
                            
                    
                        {{entry.graduateYear}}
                    
                
            
            {% endfor %} }, 1000);

**Tags:** entries, craft3

> **Comments:**
> **username_1**: Twig is pre rendered on the server so I'm not sure what you're trying to accomplish here? Do you want to show a new randomly chosen entry each minute?  
> **username_0**: I want to get random entries from craft CP. like randomly showing images every minutes 6 at a time and looping through the others.  
> **username_1**: You'll have to output the html for all of them beforehand, in the order you choose, and than use javascript on the frontend to do the switching every minute. I'm en route at the moment, i'll try and whip the above into a proper answer when I get back.  

---

## 1 answers

### Answer by username_1 on 2017-07-24. Score: 1

See below for some twig code to get you started, I omitted the actual HTML output for the individual items to better keep the overview. 
Whats happening is, you get all (or a reasonable big amount amount) of your entries, and start looping over them. 
The first time, you open a div that will contain 6 items. Afterwards, each time the loop index can be divised by 6 (aka, 6 more items have been looped over) you close the container div & open a new one. 
Than finally after the last iteration, you close the container div again. 
Making the 6 items hide or display you can do with Javascript. Let me know if you need extra pointers on that. 
{% for entry in craft.entries.section('alumni').order('RAND()')}
    {% if loop.first %}
        
    {% endif %}

    {# Build item output here #}

    {% if loop.index is divisible by(6) %}
        
        
    {% endif %}

    {% if loop.last %}
        
    {% endif %}
{% endfor %}

Info on divisible by


---

