Answers.Body: <p>This is a change in behaviour from Craft 2 to Craft 3 and <a href="https://craftcms.com/docs/3.x/upgrade.html#cloning-element-queries" rel="nofollow noreferrer">here is the explanation</a>.</p>
  <p>In short, you need to <code>clone</code> your query (<a href="https://craftcms.com/docs/3.x/dev/functions.html#clone" rel="nofollow noreferrer">docs</a>), something like the below should work:</p>
  <pre class="lang-twig prettyprint-override"><code>{# 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 %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-29T14:36:19.897Z
Answers.Text: Thanks! I missed that change, and somehow it hasn't come up for me until now.
Answers.UserDisplayName: artmem
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-29T10:31:48.733Z
Answers.LastActivityDate: 2021-03-29T10:31:48.733Z
Answers.UserDisplayName: Oli
Body: <p>I have a content builder matrix that I'm looping through to build my page. That code works with no problems.</p>
  <pre><code>{% set content = entry.pageBuilder.all() %}
  {% for block in content %}
      {% include &quot;blocks/_&quot; ~ block.type ignore missing %}
  {% endfor %}
  </code></pre>
  <p>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:</p>
  <pre><code>{% set blurb = entry.pageBuilder.type('copy,faq').limit(1).all() %}
  </code></pre>
  <p>But, if I move it below the &quot;set content...&quot; chunk, it works as expected.</p>
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-27T06:52:42.787Z
Comments.Text: If you change ‘blurb’ to another word does it have any effect? If you print the block.type rather than import the partial does it display the types as expected?
Comments.UserDisplayName: Joe Prisk
Tags: <templating>
Title: Order of {% set %} tags changing output unexpectedly
ThreadText: # Order of {% set %} tags changing output unexpectedly
  
  (Asked by: username_0 on 2021-03-26)
  
  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 "blocks/_" ~ 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 "set content..." chunk, it works as expected.
  
  It seems like these should be two completely unrelated chunks of code, and I don't understand why the "set blurb..." code is interfering with the other code when placed above it. Am I missing something?
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: If you change ‘blurb’ to another word does it have any effect? If you print the block.type rather than import the partial does it display the types as expected?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-03-29. Score: 2 | Accepted answer
  
  This is a change in behaviour from Craft 2 to Craft 3 and [here is the explanation](https://craftcms.com/docs/3.x/upgrade.html#cloning-element-queries).
  
  In short, you need to `clone` your query ([docs](https://craftcms.com/docs/3.x/dev/functions.html#clone)), something like the below should work:
  
  ```twig
  {# 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 "blocks/_" ~ block.type ignore missing %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks! I missed that change, and somehow it hasn't come up for me until now.  
  
  ---
  
  