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 %}
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.
|length
is exactly what I would do too.
Commented
May 11, 2018 at 22:46
Queries
is deprecated. You should take a look into your deprecator logs