I know im doing something small wrong but I cant see what at this point.
I have a channel called 'testimonialEntries' and I want to randomly output one of these entries on seperate pages. I cant output the matrix block in 'testimonialEntries' but i can the title, so i know its working just not accessing the matrix block.
{% for entries in craft.entries.section('testimonalEntries').orderBy('RAND()').limit(1).all() %}
{% block in entry.matrixBlock %}
<article>
<h4>{{ block.heading }}</h4>]
<p>{{ block.bodyContent }}</p>
</article>
{% endfor %}{% endfor %}
In this example im getting the entry title, but how do i also get a matrix block?
Edit: AM I getting close?
{% set testimonialEntry = craft.entries.section('testimonalEntries').orderBy('RAND()').limit(1).with(['testimonial']).one() %}
{% set testimonialEntryMatrixBlocks = testimonialEntry.testimonial %}
{% if testimonialEntryMatrixBlocks %}
<article>
<p>{{ testimonialEntryMatrixBlocks.body }}</p>
<p>{{ testimonialEntryMatrixBlocks.quote }}</p>
<p>{{ testimonialEntryMatrixBlocks.role }}</p>
</article>
{% endif %}
Ok final edit incase anyone else runs across this: It Works!
{% set testimonialEntry = craft.entries.section('testimonalEntries').orderBy('RAND()').limit(1).with(['testimonial']).one() %}
{% set testimonialEntryMatrixBlocks = testimonialEntry.testimonial %}
{% if testimonialEntryMatrixBlocks %}
{% for testimonial in testimonialEntryMatrixBlocks %}
<article>
<p>{{ testimonial.body }}</p>
<p>{{ testimonial.quote }}</p>
<p>{{ testimonial.role }}</p>
</article>
{% endfor %}
{% endif %}