<p>There's a special <a href="http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable" rel="nofollow"><code>loop</code></a> variable available in for loops which provides info about the iteration.
In your case you'd just insert that list item after the 2nd iteration:</p>

<pre><code>{% for entry in entriesOnPage %}
    &lt;li class="class-A"&gt;{{ entry.title }}&lt;/li&gt;

    {% if loop.index == 2 %}
        &lt;li class="class-B"&gt;I'm am different&lt;/li&gt;
    {% endif %}
{% endfor %}
</code></pre>

<p>If you want to do this only on select pagination pages, you'd additionally compare  against the <a href="http://buildwithcraft.com/docs/templating/paginate#the-paginate-variable" rel="nofollow"><code>paginate</code></a> variable available in between <code>paginate</code> tags:</p>

<pre><code>{% if loop.index == 2 and paginate.currentPage == 12 %}
</code></pre>

CC BY-SA 3.0
2015-05-14T17:27:47.693Z
This was perfect! Thanks for the quick and easy answer.
Ricardo Henriquez
CC BY-SA 3.0
2015-05-14T16:44:35.520Z
2015-05-14T17:09:02.900Z
2015-05-14T17:09:02.900Z
carlcs
<p>You could add a new entry type to your "example" section with a single field of type entries field and use that to "pull in" your special entry into your section.</p>

<p>Within your entries loop you can check for the entry's entry type to switch classes:</p>

<pre><code>{% set class = entry.type == 'special' ? 'class-B' : 'class-A' %}
</code></pre>

<p>or to include different template partials:</p>

<pre><code>{% include '_partials/example_index/' ~ entry.type %}
</code></pre>

CC BY-SA 3.0
2015-05-14T16:55:32.407Z
2015-05-14T17:07:05.397Z
2015-05-14T17:07:05.397Z
carlcs
<p>I want to apologize if I'm not asking the question correctly, but basically this is what I want to do:</p>

<p>I have this craft.entries:</p>

<pre><code>{% paginate craft.entries.section('example').limit(10) as entriesOnPage %}
  {% for entry in entriesOnPage %}
    &lt;li class="class-A"&gt;{{ entry.title }}&lt;/li&gt;
  {% endfor %}
{% endpaginate %}
</code></pre>

<p>How do I insert another list-item with a different class that has to always stay in same position. For this example in the 3rd spot, to look something like this:</p>

<pre><code>&lt;li class="class-A"&gt;I'm a title&lt;/li&gt;
&lt;li class="class-A"&gt;I'm a title&lt;/li&gt;
&lt;li class="class-B"&gt;I'm am different&lt;/li&gt;
&lt;li class="class-A"&gt;I'm a title&lt;/li&gt;
....
</code></pre>

<p>Once again, I apologize if I'm not using the right terms, but hopefully the code can explain it. </p>

<p>Thanks!</p>

<templating><entries><sorting><custom>
How do I insert a special entry into a sections list?
# How do I insert a special entry into a sections list?

(Asked by: username_0 on 2015-05-14)

I want to apologize if I'm not asking the question correctly, but basically this is what I want to do:
I have this craft.entries:
{% paginate craft.entries.section('example').limit(10) as entriesOnPage %}
  {% for entry in entriesOnPage %}
    {{ entry.title }}
  {% endfor %}
{% endpaginate %}

How do I insert another list-item with a different class that has to always stay in same position. For this example in the 3rd spot, to look something like this:
I'm a title
I'm a title
I'm am different
I'm a title
....

Once again, I apologize if I'm not using the right terms, but hopefully the code can explain it. 
Thanks!

**Tags:** templating, entries, sorting, custom


---

## 2 answers

### Answer by username_1 on 2015-05-14. Score: 3 | Accepted answer

There's a special loop variable available in for loops which provides info about the iteration.
In your case you'd just insert that list item after the 2nd iteration:
{% for entry in entriesOnPage %}
    {{ entry.title }}

    {% if loop.index == 2 %}
        I'm am different
    {% endif %}
{% endfor %}

If you want to do this only on select pagination pages, you'd additionally compare  against the paginate variable available in between paginate tags:
{% if loop.index == 2 and paginate.currentPage == 12 %}

> **Comments:**
> **username_0**: This was perfect! Thanks for the quick and easy answer.  

---

### Answer by username_1 on 2015-05-14. Score: 1

You could add a new entry type to your "example" section with a single field of type entries field and use that to "pull in" your special entry into your section.
Within your entries loop you can check for the entry's entry type to switch classes:
{% set class = entry.type == 'special' ? 'class-B' : 'class-A' %}

or to include different template partials:
{% include '_partials/example_index/' ~ entry.type %}


---

