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" %}
        <div class="col-md-4">
                <p>{{ block.quote|raw }}</p>
                <footer>{{ block.caption }} </footer>
    {% elseif block.type =="text" %}
        <div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30">{{ block.column1 }}</div>
        <div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30">{{ block.column2 }}</div>
    {% endif %}

{% endfor %}

1 Answer 1


You could query for your two blocks individually.

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

    <p>{{ quoteBlock.quote|raw }}</p>
    <footer>{{ quoteBlock.caption }} </footer>

<div>{{ textBlock.column1 }}</div>
<div>{{ textBlock.column2 }}</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.