Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T17:27:35.173Z
Answers.LastActivityDate: 2014-07-17T17:27:35.173Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Bryan Redeagle
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T17:21:01.910Z
Answers.LastActivityDate: 2014-07-17T17:21:01.910Z
Answers.UserDisplayName: Marion Newlevant
Body: <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>
  
Tags: <templating><categories>
Title: How do I list category name?
ThreadText: # 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'}) %}
      <div class="article">
          <p class="category">{{ entry.blogCategory }}</p>
          <a href="{{ entry.url }}" class="headline">{{ entry.title }}</a>
      </div>
  {% 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](http://buildwithcraft.com/docs/templating/elementcriteriamodel) is "used to fetch elements with a given set of parameters." `{{ entry.blogCategory }}` hasn't yet fetched your category element.
  
  You need:
  
  ```
  <p class="category">{{ entry.blogCategory.first }}</p>
  
  ```
  
  if you are positive there is exactly one of them, or more generally:
  
  ```
  {% for c in entry.blogCategory %}
    <p class="category">{{ c }}</p>
  {% endfor %}
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2014-07-17. Score: 2
  
  There are several ways. Categories in Craft are [elements](http://buildwithcraft.com/docs/plugins/working-with-elements). Most things are. I wrote [an answer about relating elements here](https://craftcms.stackexchange.com/questions/630/how-do-i-pull-related-entries-and-assets/640#640). For you, if you know there's just one you can:
  
  ```
  <p class="category">{{ entry.blogCategory.first() }}</p>
  
  ```
  
  If there's many you can loop over them:
  
  ```
  {% for category in entry.blogCategory %}
      <p class="category">{{ category }}</p>
  {% endfor %}
  
  ```
  
  If you just want a comma separated list:
  
  ```
  <p class="category">{{ entry.blogCategory.find()|join(", ") }}</p>
  
  ```
  
  I haven't tried the last one, but it should theoretically work.
  
  
  ---
  
  