<p>You could query for your two blocks individually.</p>

<pre><code>{% set quoteBlock = entry.intro.type('quote').first() %}
{% set textBlock = entry.intro.type('text').order('RAND()').first() %}

&lt;blockquote&gt;
    &lt;p&gt;{{ quoteBlock.quote|raw }}&lt;/p&gt;
    &lt;footer&gt;{{ quoteBlock.caption }} &lt;/footer&gt;
&lt;/blockquote&gt;

&lt;div&gt;{{ textBlock.column1 }}&lt;/div&gt;
&lt;div&gt;{{ textBlock.column2 }}&lt;/div&gt;
</code></pre>

CC BY-SA 3.0
2015-10-30T08:44:42.137Z
2015-10-30T08:44:42.137Z
carlcs
<p>I have a Matrix block with 2 types: quotes and text. The first block contains a quote and a text. The second and following ones only contain quotes.</p>

<p>I want the type text to be limited to 1 and the type quotes limited to one at a time displayed randomly.
Can't figure out how?</p>

<pre><code>{% for block in entry.intro %}

    {% if block.type == "quote" %}
        &lt;div class="col-md-4"&gt;
            &lt;blockquote&gt;
                &lt;p&gt;{{ block.quote|raw }}&lt;/p&gt;
                &lt;footer&gt;{{ block.caption }} &lt;/footer&gt;
            &lt;/blockquote&gt;
        &lt;/div&gt;
    {% elseif block.type =="text" %}
        &lt;div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30"&gt;{{ block.column1 }}&lt;/div&gt;
        &lt;div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30"&gt;{{ block.column2 }}&lt;/div&gt;
    {% endif %}

{% endfor %}
</code></pre>

<matrix><loop><random>
Random quotes in matrix block type
# Random quotes in matrix block type

(Asked by: username_0 on 2015-10-29)

I have a Matrix block with 2 types: quotes and text. The first block contains a quote and a text. The second and following ones only contain quotes.
I want the type text to be limited to 1 and the type quotes limited to one at a time displayed randomly.
Can't figure out how?
{% for block in entry.intro %}

    {% if block.type == "quote" %}
        
            
                {{ block.quote|raw }}
                {{ block.caption }} 
            
        
    {% elseif block.type =="text" %}
        {{ block.column1 }}
        {{ block.column2 }}
    {% endif %}

{% endfor %}

**Tags:** matrix, loop, random

---

## 1 answers

### Answer by username_1 on 2015-10-30. Score: 1 | Accepted answer

You could query for your two blocks individually.
{% set quoteBlock = entry.intro.type('quote').first() %}
{% set textBlock = entry.intro.type('text').order('RAND()').first() %}


    {{ quoteBlock.quote|raw }}
    {{ quoteBlock.caption }} 


{{ textBlock.column1 }}
{{ textBlock.column2 }}


---

