<p>This solves my problem:</p>

<pre><code>{% for block in entry.transformerProductNavigation %}
{% set chosenCategory = block.transformer.last() %}

      {# set a variable – chosenCategory to the 'last' category ensuring any nested categories are accessible   #}
      &lt;a href="{{ chosenCategory.slug }}"&gt;{{ chosenCategory.title }}&lt;/a&gt;

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

<p>Thanks to this answer: <a href="https://craftcms.stackexchange.com/questions/22962/how-to-fetch-only-selected-child-category">How to fetch only selected child category?</a>. </p>

CC BY-SA 4.0
2019-11-21T14:42:06.417Z
2019-11-21T14:42:06.417Z
user2569
<p>I'm using a matrix field to allow the author to add products they can link to category pages, but my code:</p>

<pre><code>{% for block in entry.transformerProductNavigation %}
 &lt;a href="{{ block.transformer.one.url }}"&gt;{{ block.transformer.one.title }}&lt;/a&gt;
{% endfor %}
</code></pre>

<p>outputs the parent category, can I somehow display the nested category – as you would if it was an entry field and nested entries?</p>

CC BY-SA 4.0
2019-11-20T16:54:32.600Z
With an entry field you can access the nested entries so not sure what the difference is here
user2569
<matrix><categories><nested>
Link to a nested category
# Link to a nested category

(Asked by: username_0 on 2019-11-20)

I'm using a matrix field to allow the author to add products they can link to category pages, but my code:
{% for block in entry.transformerProductNavigation %}
 {{ block.transformer.one.title }}
{% endfor %}

outputs the parent category, can I somehow display the nested category – as you would if it was an entry field and nested entries?

**Tags:** matrix, categories, nested

> **Comments:**
> **username_0**: With an entry field you can access the nested entries so not sure what the difference is here  

---

## 1 answers

### Answer by username_0 on 2019-11-21. Score: 2 | Accepted answer

This solves my problem:
{% for block in entry.transformerProductNavigation %}
{% set chosenCategory = block.transformer.last() %}

      {# set a variable – chosenCategory to the 'last' category ensuring any nested categories are accessible   #}
      {{ chosenCategory.title }}

{% endfor %}

Thanks to this answer: How to fetch only selected child category?.


---

