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 %}
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityThat 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.
Queries
is deprecated. You should take a look into your deprecator logs – Robin Schambach May 11 '18 at 22:29