Answers.Body: <p>That is returning an <code>ElementQuery</code>. I'm assuming you only need to get the first category. You need to use <code>.one</code> to get the category element.</p>
  
  <pre><code>{% for row in entry.matrixField.all() %}
      {{ row.matrixChild.one.slug }}
  {% endfor %}
  </code></pre>
  
  <p>If you wish to display more than one category you can use a <code>{% nav %}</code> or <code>{% for %}</code> to loop through them. See the <a href="https://docs.craftcms.com/v3/categories-fields.html" rel="nofollow noreferrer">category docs</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T22:44:46.017Z
Answers.Text: 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 :)
Answers.UserDisplayName: Vin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T22:46:58.987Z
Answers.Text: You're welcome. Adding `|length` is exactly what I would do too.
Answers.UserDisplayName: Simon Kuran
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T21:38:08.207Z
Answers.LastActivityDate: 2018-05-11T22:33:09.337Z
Answers.LastEditDate: 2018-05-11T22:33:09.337Z
Answers.UserDisplayName: Simon Kuran
Body: <p>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.</p>
  
  <pre><code>{% for row in entry.matrixField %}
  
   {{ row.matrixChild.slug }}
  
  {% endfor %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-11T22:29:00.203Z
Comments.Text: Just a side note: looping through `Queries` is deprecated. You should take a look into your deprecator logs
Comments.UserDisplayName: Robin Schambach
Tags: <matrix><craft3><slug>
Title: Matrix Field Slug Output
ThreadText: # Matrix Field Slug Output
  
  (Asked by: username_0 on 2018-05-11)
  
  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 %}
  
  ```
  
  **Tags:** matrix, craft3, slug
  
  > **Comments:**
  > **username_1**: Just a side note: looping through `Queries` is deprecated. You should take a look into your deprecator logs  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-05-11. Score: 2 | Accepted answer
  
  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](https://docs.craftcms.com/v3/categories-fields.html).
  
  > **Comments:**
  > **username_0**: Thanks username_2!  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 :)  
  > **username_2**: You're welcome. Adding `|length` is exactly what I would do too.  
  
  ---
  
  