I am not sure why, but I cannot seem to get the short name/handle/slug of a matrix field that is a category field. I need to get it's slug.

{% for row in entry.matrixField %}

 {{ row.matrixChild.slug }}

{% endfor %}
  • Just a side note: looping through Queries is deprecated. You should take a look into your deprecator logs Commented May 11, 2018 at 22:29

1 Answer 1


That is returning an ElementQuery. I'm assuming you only need to get the first category. You need to use .one to get the category element.

{% for row in entry.matrixField.all() %}
    {{ row.matrixChild.one.slug }}
{% endfor %}

If you wish to display more than one category you can use a {% nav %} or {% for %} to loop through them. See the category docs.

  • Thanks Simon! I had a few of those fields empty and I got an error so I added {% if row.matrixChild.one|length %} around it and it works :)
    – Vin
    Commented May 11, 2018 at 22:44
  • You're welcome. Adding |length is exactly what I would do too. Commented May 11, 2018 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.