<p>I noticed the same issue with live preview, but using the <code>type</code> property on the Matrix field: <a href="https://craftcms.stackexchange.com/q/8879/125">Issue with Matrix <code>type</code> property and Live Preview?</a> According to Brandon's answer this is a current bug / limitation of the Matrix field that you have to find a workaround for.</p>

<p>In this case this is rather easy, get all the blocks and use the <a href="http://twig.sensiolabs.org/doc/filters/slice.html" rel="nofollow noreferrer"><code>slice</code></a> filter to loop over a subset:</p>

<pre><code>{% for serviceBlock in entry.serviceBlocks|slice(0, 2) %}
</code></pre>

CC BY-SA 3.0
2015-06-18T15:27:41.163Z
Using slice is a seamless workaround. Thank you for the prompt answer!
Ian Nebbiolo
CC BY-SA 3.0
2015-06-18T14:51:53.803Z
2015-06-18T14:51:53.803Z
2017-04-13T12:51:00.200Z
carlcs
<p>I have a Matrix field setup and working perfectly except for one problem. </p>

<p>In my template I'm using <code>.limit</code> to only pull the first two items from the matrix field <em>(I can't use max in the field settings as I'm using the same field on other pages that allow more than two blocks to show)</em>.</p>

<p>Using the following line to pull the Matrix blocks works fine in the live preview.</p>

<pre><code>{% for serviceBlock in entry.serviceBlocks %}
</code></pre>

<p>But adding the limit stops Craft showing the blocks in the live preview. Though the rest of the template loads and updates perfectly.</p>

<pre><code>{% for serviceBlock in entry.serviceBlocks.limit(2) %}
</code></pre>

<p>I'm not getting any errors, and if I save the page and reload the live preview it will render the blocks perfectly, but not update the content live.</p>

<p>Has anyone encountered this problem, or have an idea that might help?</p>

<templating><matrix><live-preview><limit>
When using .limit on matrix blocks they don't show in live preview
# When using .limit on matrix blocks they don't show in live preview

(Asked by: username_0 on 2015-06-18)

I have a Matrix field setup and working perfectly except for one problem. 
In my template I'm using .limit to only pull the first two items from the matrix field (I can't use max in the field settings as I'm using the same field on other pages that allow more than two blocks to show).
Using the following line to pull the Matrix blocks works fine in the live preview.
{% for serviceBlock in entry.serviceBlocks %}

But adding the limit stops Craft showing the blocks in the live preview. Though the rest of the template loads and updates perfectly.
{% for serviceBlock in entry.serviceBlocks.limit(2) %}

I'm not getting any errors, and if I save the page and reload the live preview it will render the blocks perfectly, but not update the content live.
Has anyone encountered this problem, or have an idea that might help?

**Tags:** templating, matrix, live-preview, limit


---

## 1 answers

### Answer by username_1 on 2015-06-18. Score: 5 | Accepted answer

I noticed the same issue with live preview, but using the type property on the Matrix field: Issue with Matrix type property and Live Preview? According to Brandon's answer this is a current bug / limitation of the Matrix field that you have to find a workaround for.
In this case this is rather easy, get all the blocks and use the slice filter to loop over a subset:
{% for serviceBlock in entry.serviceBlocks|slice(0, 2) %}

> **Comments:**
> **username_0**: Using slice is a seamless workaround. Thank you for the prompt answer!  

---

