<p>Your first line must work. But there is a typo with double <code>))</code></p>

<pre><code>{% set entry = craft.entries.id(43).first() %}

{{ entry.title}}
</code></pre>

<p>But normally when you add a template for a specific single you doesn't have to set the entry.</p>

CC BY-SA 3.0
2016-11-22T16:20:28.960Z
I'm afraid it doesn't... even with a single )
noregt
CC BY-SA 3.0
2016-11-22T16:51:10.730Z
Sorry forgot the .first()
Maarten Heideman
CC BY-SA 3.0
2016-11-22T16:15:42.387Z
2016-11-25T13:29:06.137Z
2016-11-25T13:29:06.137Z
Maarten Heideman
<p>You need to add <code>.first</code> where you are setting the <code>entry</code> variable:</p>

<p><code>{% set entry = craft.entries.id(43).first %}</code></p>

<p>That way you can avoid doing a for loop.</p>

CC BY-SA 3.0
2016-11-22T16:22:58.887Z
2016-11-22T16:22:58.887Z
Jamie Wade
<p>This won't work in a template:</p>



<pre class="lang-twig prettyprint-override"><code>{% set entry = craft.entries.id(43) %}&lt;h1&gt;Titel: {{ entry.title }}&lt;/h1&gt;
</code></pre>

<p>But this does:</p>

<pre class="lang-twig prettyprint-override"><code>{% for entry in craft.entries.id(43) %}&lt;h1&gt;Titel: {{ entry.title }}&lt;/h1&gt;{% endfor %}
</code></pre>

<p>Is it really necessary to use the for loop? I tried to use set because I'd like to over rule the entry variable for the whole template that I'm using if a specific url is visited</p>

<pre class="lang-twig prettyprint-override"><code>{% if craft.request.segment(2)=="openings-en-trainingstijden" %} {% set entry = craft.entries.id(43) %}{% endif %} {{ entry.title }} etc..
</code></pre>

<p>Another example this code:</p>

<pre class="lang-twig prettyprint-override"><code>{% for entry1 in craft.entries.id(43) %}Titel: {{ entry1.title }}{% endfor %}
{% set entry2 = craft.entries.id(43) %}Titel: {{ entry2.title }}
</code></pre>

<p>Results in:</p>

<pre class="lang-html prettyprint-override"><code>Titel: Openings- en trainingstijden
Titel:
</code></pre>

<entries><set>
How do I set a specific entry in a template with "set"
# How do I set a specific entry in a template with "set"

(Asked by: username_0 on 2016-11-22)

This won't work in a template:
{% set entry = craft.entries.id(43) %}Titel: {{ entry.title }}

But this does:
{% for entry in craft.entries.id(43) %}Titel: {{ entry.title }}{% endfor %}

Is it really necessary to use the for loop? I tried to use set because I'd like to over rule the entry variable for the whole template that I'm using if a specific url is visited
{% if craft.request.segment(2)=="openings-en-trainingstijden" %} {% set entry = craft.entries.id(43) %}{% endif %} {{ entry.title }} etc..

Another example this code:
{% for entry1 in craft.entries.id(43) %}Titel: {{ entry1.title }}{% endfor %}
{% set entry2 = craft.entries.id(43) %}Titel: {{ entry2.title }}

Results in:
Titel: Openings- en trainingstijden
Titel:

**Tags:** entries, set

---

## 2 answers

### Answer by username_2 on 2016-11-22. Score: 5 | Accepted answer

You need to add `.first` where you are setting the `entry` variable:

`{% set entry = craft.entries.id(43).first %}`

That way you can avoid doing a for loop.


---

### Answer by username_1 on 2016-11-22. Score: 1

Your first line must work. But there is a typo with double ))
{% set entry = craft.entries.id(43).first() %}

{{ entry.title}}

But normally when you add a template for a specific single you doesn't have to set the entry.

> **Comments:**
> **username_0**: I'm afraid it doesn't... even with a single )  
> **username_1**: Sorry forgot the .first()  

---

