<p>There are several ways. Categories in Craft are <a href="http://buildwithcraft.com/docs/plugins/working-with-elements" rel="nofollow noreferrer">elements</a>. Most things are. I wrote <a href="https://craftcms.stackexchange.com/questions/630/how-do-i-pull-related-entries-and-assets/640#640">an answer about relating elements here</a>. For you, if you know there's just one you can:</p>

<pre><code>&lt;p class="category"&gt;{{ entry.blogCategory.first() }}&lt;/p&gt;
</code></pre>

<p>If there's many you can loop over them:</p>

<pre><code>{% for category in entry.blogCategory %}
    &lt;p class="category"&gt;{{ category }}&lt;/p&gt;
{% endfor %}
</code></pre>

<p>If you just want a comma separated list:</p>

<pre><code>&lt;p class="category"&gt;{{ entry.blogCategory.find()|join(", ") }}&lt;/p&gt;
</code></pre>

<p>I haven't tried the last one, but it should theoretically work.</p>

CC BY-SA 3.0
2014-07-17T17:27:35.173Z
2014-07-17T17:27:35.173Z
2017-04-13T12:51:00.303Z
Bryan Redeagle
<p>An <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel">ElementCriteriaModel</a> is "used to fetch elements with a given set of parameters." <code>{{ entry.blogCategory }}</code> hasn't yet fetched your category element.</p>

<p>You need:</p>

<pre><code>&lt;p class="category"&gt;{{ entry.blogCategory.first }}&lt;/p&gt;
</code></pre>

<p>if you are positive there is exactly one of them, or more generally:</p>

<pre><code>{% for c in entry.blogCategory %}
  &lt;p class="category"&gt;{{ c }}&lt;/p&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-07-17T17:21:01.910Z
2014-07-17T17:21:01.910Z
Marion Newlevant
<p>Forgive the simplicity of this question but I am in the early stages of my first Craft implementation.</p>

<p>My simple question is: how do I display a category name in a template. This is the code I am using:</p>

<pre><code>{% for entry in craft.entries.find({section: 'blog', limit: '3'}) %}
    &lt;div class="article"&gt;
        &lt;p class="category"&gt;{{ entry.blogCategory }}&lt;/p&gt;
        &lt;a href="{{ entry.url }}" class="headline"&gt;{{ entry.title }}&lt;/a&gt;
    &lt;/div&gt;
{% endfor %}
</code></pre>

<p>The error I am getting says "Object of class Craft\ElementCriteriaModel could not be converted to string"</p>

<p>Any help is appreciated. </p>

<templating><categories>
How do I list category name?
# How do I list category name?

(Asked by: username_0 on 2014-07-17)

Forgive the simplicity of this question but I am in the early stages of my first Craft implementation.
My simple question is: how do I display a category name in a template. This is the code I am using:
{% for entry in craft.entries.find({section: 'blog', limit: '3'}) %}
    
        {{ entry.blogCategory }}
        {{ entry.title }}
    
{% endfor %}

The error I am getting says "Object of class Craft\ElementCriteriaModel could not be converted to string"
Any help is appreciated.

**Tags:** templating, categories


---

## 2 answers

### Answer by username_2 on 2014-07-17. Score: 9 | Accepted answer

An ElementCriteriaModel is "used to fetch elements with a given set of parameters." {{ entry.blogCategory }} hasn't yet fetched your category element.
You need:
{{ entry.blogCategory.first }}

if you are positive there is exactly one of them, or more generally:
{% for c in entry.blogCategory %}
  {{ c }}
{% endfor %}


---

### Answer by username_1 on 2014-07-17. Score: 2

There are several ways. Categories in Craft are elements. Most things are. I wrote an answer about relating elements here. For you, if you know there's just one you can:
{{ entry.blogCategory.first() }}

If there's many you can loop over them:
{% for category in entry.blogCategory %}
    {{ category }}
{% endfor %}

If you just want a comma separated list:
{{ entry.blogCategory.find()|join(", ") }}

I haven't tried the last one, but it should theoretically work.


---

