<p>I have a Video section with a field called <code>videoCategory</code>. I'm trying to pull in the first category on the _entry.html template.</p>

<p>I'm pretty much following the the last example in the documentation at: <a href="http://buildwithcraft.com/docs/categories-fields" rel="nofollow">http://buildwithcraft.com/docs/categories-fields</a></p>

<p>...with this code:</p>

<pre><code> {% set entryCategory = entry.videoCategory.first() %}
 {% if entryCategory %}
   &lt;h1&gt;{% for category in entryCategory %}&lt;a href=""&gt;{{ category.title }}&lt;/a&gt; {% endfor %}&lt;/h1&gt;
 {% endif %}
</code></pre>

<p>But I can't get around this error message:</p>

<blockquote>
  <p><em>Impossible to access an attribute ("title") on a string variable ("19")</em></p>
</blockquote>

<p>What is it that I'm missing?</p>

<categories><entry><conditional>
Impossible to access an attribute (title) on a string variable
# Impossible to access an attribute (title) on a string variable

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

I have a Video section with a field called videoCategory. I'm trying to pull in the first category on the _entry.html template.
I'm pretty much following the the last example in the documentation at: http://buildwithcraft.com/docs/categories-fields
...with this code:
 {% set entryCategory = entry.videoCategory.first() %}
 {% if entryCategory %}
   {% for category in entryCategory %}{{ category.title }} {% endfor %}
 {% endif %}

But I can't get around this error message:

Impossible to access an attribute ("title") on a string variable ("19")

What is it that I'm missing?

**Tags:** categories, entry, conditional

---

## 0 answers

