<p>Assuming your categories are accessible from a Categories field called 'productCategory', and you only have 1 category assigned to each product, you can display the name of the parent category with:</p>

<pre><code>{{ entry.productCategory.one() }}
</code></pre>

<p>Or you can loop through multiple Categories with:</p>

<pre><code>{% for category in entry.productCategory.all() %}
    {{ category.title }}
{% endfor %}
</code></pre>

<hr>

<p>And to get the category link for your breadcrumb, you could use something like:</p>

<pre><code>{{ entry.productCategory.one().slug }}
</code></pre>

CC BY-SA 4.0
2018-07-12T13:03:36.577Z
Firstly, many thanks for taking the time to replay to my question - it is very much appreciated.

Sorry, but I'm confused where you've used 'category' as the field name.  And I'm not able to get this to work:

This, simply to display the parent category of the entry (_entry.html) on the page, where 'products' is the handle of the category group:

{% for category in entry.products.all() %}
    {{ category.title }}
{% endfor %}

And I'm altogether lost with code for adding a link to use in a breadcrumb.

Many thanks!
MGX
CC BY-SA 4.0
2018-07-12T13:30:36.620Z
@MGX when you are editing your products in the CP, how are you assigning a category to them? I'm guessing/hoping you have a field that you use to set the category... this is what we need to know the name of
James Greig
CC BY-SA 4.0
2018-07-12T15:03:43.093Z
Yes - a category is assigned to each product via a category field in the CP, the handle for this is 'productCategory'.  The handle of the category group is called 'products'.  Many thanks.
MGX
CC BY-SA 4.0
2018-07-12T19:43:30.433Z
@MGX Just edited my answer to use `productCategory` instead of `category`, see if that does the trick for you? If not suggesting seeking help on the Craft Slack channel.
James Greig
CC BY-SA 4.0
2018-07-13T08:00:13.353Z
Yes - that's very helpful.  Many thanks for taking the time to help with this, it's very much appreciated.  I have a problem with 'clean' URL's at the moment, so I'm getting a 404 error unless the url is in this format: /products/?category=name-of-category'.  If the URL is '/products/name-of-category' it fails (404).  Not sure what's causing that...routes isn't helping  :(
MGX
CC BY-SA 4.0
2018-07-12T11:55:05.370Z
2018-07-12T19:42:40.250Z
2018-07-12T19:42:40.250Z
James Greig
<p>I have a simple Craft 3 website, with products that are organised in categories.</p>

<p>Can someone please tell me how to do the following:</p>

<p>On the the individual product pages (_entry.html) display a 'breadcrumb' menu that includes the parent category name/url (I've followed the few examples posted here - they don't work).</p>

<p>And also be able to simply display the name of the parent category of the product in text (e.g. to use as part of the h1 title for the product page).</p>

<p>Many thanks for your help - it is very much appreciated!</p>

CC BY-SA 4.0
2018-07-12T11:41:13.113Z
Can you share the code you've got for the breadcrumb so far?
James Greig
CC BY-SA 4.0
2018-07-12T13:07:02.107Z
{% for category in entry.products.all() %}
      <p>{{ category.title }}</p>
     {% endfor %}
MGX
<category>
How to display the parent category on an entry page?
# How to display the parent category on an entry page?

(Asked by: username_0 on 2018-07-12)

I have a simple Craft 3 website, with products that are organised in categories.

Can someone please tell me how to do the following:

On the the individual product pages (\_entry.html) display a 'breadcrumb' menu that includes the parent category name/url (I've followed the few examples posted here - they don't work).

And also be able to simply display the name of the parent category of the product in text (e.g. to use as part of the h1 title for the product page).

Many thanks for your help - it is very much appreciated!

**Tags:** category

> **Comments:**
> **username_1**: Can you share the code you've got for the breadcrumb so far?  
> **username_0**: {% for category in entry.products.all() %}       <p>{{ category.title }}</p>      {% endfor %}  

---

## 1 answers

### Answer by username_1 on 2018-07-12. Score: 1 | Accepted answer

Assuming your categories are accessible from a Categories field called 'productCategory', and you only have 1 category assigned to each product, you can display the name of the parent category with:
{{ entry.productCategory.one() }}

Or you can loop through multiple Categories with:
{% for category in entry.productCategory.all() %}
    {{ category.title }}
{% endfor %}


And to get the category link for your breadcrumb, you could use something like:
{{ entry.productCategory.one().slug }}

> **Comments:**
> **username_0**: Firstly, many thanks for taking the time to replay to my question - it is very much appreciated.  Sorry, but I'm confused where you've used 'category' as the field name.  And I'm not able to get this to work:  This, simply to display the parent category of the entry (_entry.html) on the page, where 'products' is the handle of the category group:  {% for category in entry.products.all() %}     {{ category.title }} {% endfor %}  And I'm altogether lost with code for adding a link to use in a breadcrumb.  Many thanks!  
> **username_1**: @username_0 when you are editing your products in the CP, how are you assigning a category to them? I'm guessing/hoping you have a field that you use to set the category... this is what we need to know the name of  
> **username_0**: Yes - a category is assigned to each product via a category field in the CP, the handle for this is 'productCategory'.  The handle of the category group is called 'products'.  Many thanks.  
> **username_1**: @username_0 Just edited my answer to use `productCategory` instead of `category`, see if that does the trick for you? If not suggesting seeking help on the Craft Slack channel.  
> **username_0**: Yes - that's very helpful.  Many thanks for taking the time to help with this, it's very much appreciated.  I have a problem with 'clean' URL's at the moment, so I'm getting a 404 error unless the url is in this format: /products/?category=name-of-category'.  If the URL is '/products/name-of-category' it fails (404).  Not sure what's causing that...routes isn't helping  :(  

---

