Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-22T16:20:28.960Z
Answers.Text: I'm afraid it doesn't... even with a single )
Answers.UserDisplayName: noregt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-22T16:51:10.730Z
Answers.Text: Sorry forgot the .first()
Answers.UserDisplayName: Maarten Heideman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-22T16:15:42.387Z
Answers.LastActivityDate: 2016-11-25T13:29:06.137Z
Answers.LastEditDate: 2016-11-25T13:29:06.137Z
Answers.UserDisplayName: Maarten Heideman
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-22T16:22:58.887Z
Answers.LastActivityDate: 2016-11-22T16:22:58.887Z
Answers.UserDisplayName: Jamie Wade
Body: <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>
  
Tags: <entries><set>
Title: How do I set a specific entry in a template with "set"
ThreadText: # 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:
  
  ```twig
  {% set entry = craft.entries.id(43) %}<h1>Titel: {{ entry.title }}</h1>
  
  ```
  
  But this does:
  
  ```twig
  {% for entry in craft.entries.id(43) %}<h1>Titel: {{ entry.title }}</h1>{% 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
  
  ```twig
  {% if craft.request.segment(2)=="openings-en-trainingstijden" %} {% set entry = craft.entries.id(43) %}{% endif %} {{ entry.title }} etc..
  
  ```
  
  Another example this code:
  
  ```twig
  {% for entry1 in craft.entries.id(43) %}Titel: {{ entry1.title }}{% endfor %}
  {% set entry2 = craft.entries.id(43) %}Titel: {{ entry2.title }}
  
  ```
  
  Results in:
  
  ```html
  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()  
  
  ---
  
  