Order of {% set %} tags changing output unexpectedly I have a content builder matrix that I'm looping through to build my page. That code works with no problems.
{% set content = entry.pageBuilder.all() %}
{% for block in content %}
    {% include &quot;blocks/_&quot; ~ block.type ignore missing %}
{% endfor %}

Above that block, in the same template, I'm trying to create a text blurb from one particular field type within that matrix. When I try to define what field to pull the blurb from, suddenly the above code only outputs the content of the blurb field. This is the code that breaks my template:
{% set blurb = entry.pageBuilder.type('copy,faq').limit(1).all() %}

But, if I move it below the &quot;set content...&quot; chunk, it works as expected.
It seems like these should be two completely unrelated chunks of code, and I don't understand why the &quot;set blurb...&quot; code is interfering with the other code when placed above it. Am I missing something?
This is a change in behaviour from Craft 2 to Craft 3 and here is the explanation.
In short, you need to clone your query (docs), something like the below should work:
{# Initiate your query #}
{% set content = entry.pageBuilder %}

{# Clone the original query to get your blurb #}
{% set blurb = clone(content).type('copy,faq').limit(1).all() %}

{# Get everything #}
{% for block in content.all() %}
    {% include &quot;blocks/_&quot; ~ block.type ignore missing %}
{% endfor %}