Answers.Body: <p>Because the <code>descendantOf</code> function expects a parameter of type <code>ElementInterface</code> or an integer</p>
  
  <pre><code> /**
   * Sets the [[descendantOf]] property.
   *
   * @param int|ElementInterface|null $value The property value
   *
   * @return static self reference
   */
  public function descendantOf($value);
  </code></pre>
  
  <p>You'll have to insert the ID of your <code>accessories</code> element or the element itself</p>
  
  <pre><code>{% accessories = craft.categories.title('accessories').first() %}
  {% set categoryGroup = craft.categories.group('productTypes').descendantOf(accessories) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-19T11:14:49.970Z
Answers.LastActivityDate: 2018-03-19T11:14:49.970Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I would like to select just the children of any given main category (eg. Accessories, Stomps in the picture), regardless of segments in my URL.</p>
  
  <p>I've been trying to understand why the code below won't work.</p>
  
  <p><a href="https://i.sstatic.net/z84Mf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/z84Mf.png" alt="I would like to select just the children of any given main category (eg. Accessories, Stomps"></a></p>
  
  <p>This just won't work. Why?</p>
  
  <pre><code>{% set categoryGroup = craft.categories.group('productTypes').descendantOf('accessories') %}
  &lt;ul&gt;
      {% for category in categoryGroup %}
          &lt;li class="category"&gt;{{ category.title }}&lt;/li&gt;    
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Tags: <children>
Title: Get category children
ThreadText: # Get category children
  
  (Asked by: username_0 on 2018-03-19)
  
  I would like to select just the children of any given main category (eg. Accessories, Stomps in the picture), regardless of segments in my URL.
  
  I've been trying to understand why the code below won't work.
  
  [![I would like to select just the children of any given main category (eg. Accessories, Stomps](https://i.sstatic.net/z84Mf.png)](https://i.sstatic.net/z84Mf.png)
  
  This just won't work. Why?
  
  ```
  {% set categoryGroup = craft.categories.group('productTypes').descendantOf('accessories') %}
  <ul>
      {% for category in categoryGroup %}
          <li class="category">{{ category.title }}</li>    
      {% endfor %}
  </ul>
  
  ```
  
  **Tags:** children
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-03-19. Score: 2 | Accepted answer
  
  Because the `descendantOf` function expects a parameter of type `ElementInterface` or an integer
  
  ```
   /**
   * Sets the [[descendantOf]] property.
   *
   * @param int|ElementInterface|null $value The property value
   *
   * @return static self reference
   */
  public function descendantOf($value);
  
  ```
  
  You'll have to insert the ID of your `accessories` element or the element itself
  
  ```
  {% accessories = craft.categories.title('accessories').first() %}
  {% set categoryGroup = craft.categories.group('productTypes').descendantOf(accessories) %}
  
  ```
  
  
  ---
  
  