Answers.Body: <p>I'm not really sure why craft is working that way and I'm not really sure if my way is the intended to solve it but it works at least for me. Make sure you select the one that fits best for you. Usually the best is the third one.</p>
  
  <p><strong>First solution</strong><br>
  If you have a limitation in your field how many categories you can link the <code>.last()</code> function would suit since your child is always the last element and your parent is the first one.</p>
  
  <pre><code>{% set category = entry.fieldHandle.last() %}
  </code></pre>
  
  <p>But this does not work if you are going to relate multiple Cateogies</p>
  
  <p><strong>Second Solution</strong><br>
  If your selected categories are always at level 2 and never at level 1 you can do the following. This works for multiple categories as well </p>
  
  <pre><code>{% set categories = entry.fieldHandle.level(2).all() %}
  {% for category in categories %}
      {{ category.id }}
      {{ category.title }}&lt;br&gt;
  {% endfor %}
  </code></pre>
  
  <p><strong>Third solution</strong><br>
  Change your matrix structure into two different channels (countries and continent) and relate your continent with your countries. In your relation field you restrict the selection to those two groups.
  That way a user can select the country and/or a continent individually.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-28T07:10:53.227Z
Answers.Text: I haven't used this yet, I am sure this will work. Thank you so much.
Answers.UserDisplayName: Mohit Prajapati
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-27T10:17:18.643Z
Answers.LastActivityDate: 2017-11-27T10:25:50.813Z
Answers.LastEditDate: 2017-11-27T10:25:50.813Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I have some parent and their child categories which has more than one child.</p>
  
  <p>In an entry I have a category field where I selected a single child category (Bourbon) which is visible like so:</p>
  
  <p><a href="https://i.sstatic.net/JBgOX.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JBgOX.jpg" alt="enter image description here"></a></p>
  
  <p>Now I want to show the title and URL of the only selected single child category which is Bourbon.</p>
  
Tags: <craft-features><craft3>
Title: How to fetch only selected child category?
ThreadText: # How to fetch only selected child category?
  
  (Asked by: username_0 on 2017-11-27)
  
  I have some parent and their child categories which has more than one child.
  
  In an entry I have a category field where I selected a single child category (Bourbon) which is visible like so:
  
  [![enter image description here](https://i.sstatic.net/JBgOX.jpg)](https://i.sstatic.net/JBgOX.jpg)
  
  Now I want to show the title and URL of the only selected single child category which is Bourbon.
  
  **Tags:** craft-features, craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-27. Score: 2
  
  I'm not really sure why craft is working that way and I'm not really sure if my way is the intended to solve it but it works at least for me. Make sure you select the one that fits best for you. Usually the best is the third one.
  
  **First solution**  
  If you have a limitation in your field how many categories you can link the `.last()` function would suit since your child is always the last element and your parent is the first one.
  
  ```
  {% set category = entry.fieldHandle.last() %}
  
  ```
  
  But this does not work if you are going to relate multiple Cateogies
  
  **Second Solution**  
  If your selected categories are always at level 2 and never at level 1 you can do the following. This works for multiple categories as well
  
  ```
  {% set categories = entry.fieldHandle.level(2).all() %}
  {% for category in categories %}
      {{ category.id }}
      {{ category.title }}<br>
  {% endfor %}
  
  ```
  
  **Third solution**  
  Change your matrix structure into two different channels (countries and continent) and relate your continent with your countries. In your relation field you restrict the selection to those two groups.
  That way a user can select the country and/or a continent individually.
  
  > **Comments:**
  > **username_0**: I haven't used this yet, I am sure this will work. Thank you so much.  
  
  ---
  
  