<p>You should replace <code>postCategories</code> with whatever the handle of the category field is for your entry.</p>

CC BY-SA 4.0
2020-05-05T08:42:53.283Z
2020-05-05T08:42:53.283Z
Oli
<p>Thank you Oli for helping with this simple quest. Here's the code that worked for me. ("decade" being the name of the field I'm using in the backend, putting out the category group!) </p>

<pre><code>    {% for category in entry.decade.all() %}
      &lt;a href="{{ category.url }}""&gt;
        {{- category.title -}}
      &lt;/a&gt;
    {% endfor %}

  {% endif %}
</code></pre>

CC BY-SA 4.0
2020-05-05T08:43:43.713Z
2020-05-05T08:43:43.713Z
Maggie
<p>I feel like I'm missing something totally obvious here, but how do I output a category name for a category that is part of a category group on a single entry layout? The name of the category group is 'Archive' and the slug 'archive'.</p>

<p>Here is what I'm trying to do.</p>

<p><code>&lt;a href="*dynamic url to category index*"&gt;*name of category*&lt;/a&gt;</code></p>

<p>Here is what I tried </p>

<p><code>&lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;</code></p>

<p>However then I get the error "Variable "category" does not exist."</p>

<p>Trying the following code snippet from the official tutorial also did not work.</p>

<pre><code>    {% for category in entry.postCategories.all() %}
      &lt;a href="{{ category.url }}"&gt;
        {{- category.title -}}
      &lt;/a&gt;
    {% endfor %}
  {% endif %}
</code></pre>

<p>resulting in the following error: "Calling unknown method: craft\elements\Entry::postCategories()"</p>

<p>Any help to solve this probably very simple problem is appreciated. Thank you!</p>

CC BY-SA 4.0
2020-05-05T08:30:01.187Z
You should replace `postCategories` with whatever the handle of the category field is for your entry.
Oli
CC BY-SA 4.0
2020-05-05T08:35:29.193Z
@Oli Brilliant, thank you so much! I'd been looking through the official tutorials, but could not find a straight forward answer that worked for me. It's much appreciated!
Maggie
CC BY-SA 4.0
2020-05-05T08:42:50.063Z
Good news! Could you mark this as answered please?
Oli
<categories><error-message><category>
{{ category.title }} error with category groups
# {{ category.title }} error with category groups

(Asked by: username_0 on 2020-05-05)

I feel like I'm missing something totally obvious here, but how do I output a category name for a category that is part of a category group on a single entry layout? The name of the category group is 'Archive' and the slug 'archive'.
Here is what I'm trying to do.
*name of category*
Here is what I tried 
{{ category.title }}
However then I get the error "Variable "category" does not exist."
Trying the following code snippet from the official tutorial also did not work.
    {% for category in entry.postCategories.all() %}
      
        {{- category.title -}}
      
    {% endfor %}
  {% endif %}

resulting in the following error: "Calling unknown method: craft\elements\Entry::postCategories()"
Any help to solve this probably very simple problem is appreciated. Thank you!

**Tags:** categories, error-message, category

> **Comments:**
> **username_1**: You should replace `postCategories` with whatever the handle of the category field is for your entry.  
> **username_0**: @username_1 Brilliant, thank you so much! I'd been looking through the official tutorials, but could not find a straight forward answer that worked for me. It's much appreciated!  
> **username_1**: Good news! Could you mark this as answered please?  

---

## 2 answers

### Answer by username_1 on 2020-05-05. Score: 2 | Accepted answer

You should replace `postCategories` with whatever the handle of the category field is for your entry.


---

### Answer by username_0 on 2020-05-05. Score: 1

Thank you username_1 for helping with this simple quest. Here's the code that worked for me. ("decade" being the name of the field I'm using in the backend, putting out the category group!) 
    {% for category in entry.decade.all() %}
      
        {{- category.title -}}
      
    {% endfor %}

  {% endif %}


---

