<p>If might be your wording but I can see two potential answers here.</p>

<p>You either want to list categories set through a category field on the entry, in that case the code Douglas has supplied will work perfectly.</p>

<p>The other answer I can see is you have multiple categories that are assigned to an entry, and you want to list those categories out. If so, this will help:</p>

<pre><code>{# Fetch all of the categories related to this entry #}
{% set categories = craft.categories.relatedTo(entry) %}

{# Output them #}
{% for category in categories %}
    &lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;
{% endfor %}
</code></pre>

<p>Hopefully myself and Douglas have covered both bases for you here.</p>

CC BY-SA 3.0
2015-01-26T19:58:10.467Z
When trying this, I get no output, even when the entry has multiple categories set :-/
taylor
CC BY-SA 4.0
2022-06-02T23:04:49.450Z
Just for anyone seeing this 7 years later: `craft.categories().relatedTo(entry).all()` or `collect()` etc etc
Rob Hodges
CC BY-SA 3.0
2015-01-26T09:32:15.807Z
2015-01-26T09:32:15.807Z
Jamie Wade
<p>Your entry is tied to the category via the field you have made. You can access the field like every other field. </p>

<pre><code>entry.categoryFieldName.one()
</code></pre>

<p>Will get the first one</p>

CC BY-SA 4.0
2018-10-09T00:52:41.330Z
2018-10-09T00:52:41.330Z
themartin
<p>You can access the categories through the category field itself. </p>

<pre><code>{% for category in entry.categoryFieldHandle %}
    {{ category.title }}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-01-26T19:57:35.537Z
When trying this in _entry.html, I get an internal server error "Craft\EntryModel and its behaviors do not have a method or closure named "categoryFieldHandle"."
taylor
CC BY-SA 3.0
2015-01-26T20:22:11.247Z
'categoryFieldHandle' is just a placeholder for your category field name (technically called it's 'handle'). You should replace this with your field handle as defined in the field settings.
Douglas McDonald
CC BY-SA 3.0
2015-01-26T06:32:46.080Z
2015-01-26T06:32:46.080Z
Douglas McDonald
<p>For templating, I need to be able to see what the categories of the current entry is. I'm aware of how to get all categories in craft via</p>

<pre><code>{% set categories = craft.categories %}
</code></pre>

<p>however I haven't come across a way to simple get the categories that are set for the entry. Is there a simple way of doing this?</p>

<templating><category>
Get categories for current page/entry
# Get categories for current page/entry

(Asked by: username_0 on 2015-01-26)

For templating, I need to be able to see what the categories of the current entry is. I'm aware of how to get all categories in craft via
{% set categories = craft.categories %}

however I haven't come across a way to simple get the categories that are set for the entry. Is there a simple way of doing this?

**Tags:** templating, category


---

## 3 answers

### Answer by username_4 on 2015-01-26. Score: 16 | Accepted answer

You can access the categories through the category field itself. 
{% for category in entry.categoryFieldHandle %}
    {{ category.title }}
{% endfor %}

> **Comments:**
> **username_0**: When trying this in _entry.html, I get an internal server error "Craft\EntryModel and its behaviors do not have a method or closure named "categoryFieldHandle"."  
> **username_4**: 'categoryFieldHandle' is just a placeholder for your category field name (technically called it's 'handle'). You should replace this with your field handle as defined in the field settings.  

---

### Answer by username_1 on 2015-01-26. Score: 6

If might be your wording but I can see two potential answers here.
You either want to list categories set through a category field on the entry, in that case the code Douglas has supplied will work perfectly.
The other answer I can see is you have multiple categories that are assigned to an entry, and you want to list those categories out. If so, this will help:
{# Fetch all of the categories related to this entry #}
{% set categories = craft.categories.relatedTo(entry) %}

{# Output them #}
{% for category in categories %}
    {{ category.title }}
{% endfor %}

Hopefully myself and Douglas have covered both bases for you here.

> **Comments:**
> **username_0**: When trying this, I get no output, even when the entry has multiple categories set :-/  
> **username_2**: Just for anyone seeing this 7 years later: `craft.categories().relatedTo(entry).all()` or `collect()` etc etc  

---

### Answer by username_3 on 2018-10-09. Score: 1

Your entry is tied to the category via the field you have made. You can access the field like every other field. 
entry.categoryFieldName.one()

Will get the first one


---

