Answers.Body: <p>I think it's because you're trying to cram too much into your <code>entry</code> variable.  For one, <a href="https://craftcms.com/docs/templating/craft.entries#slug" rel="nofollow noreferrer"><code>.slug()</code></a> is going to return an entry with that slug, so I think that's a bit of a full stop.  For two, <a href="https://craftcms.com/docs/templating/craft.entries#descendantOf" rel="nofollow noreferrer"><code>.descendantOf()</code></a> accepts an EntryModal object, but you're feeding it a uri/slug (ie. <code>name-of-artist</code>).</p>
  
  <p>Try something like this:</p>
  
  <pre><code>{% set artistEntry = craft.entries.slug(artistParent).first %}
  {% set projectEntry = craft.entries.descendantOf(artistEntry).first %}
  </code></pre>
  
  <p>Keep in mind that <code>.descendantOf()</code> only works with structures (not channels), so I'm assuming that's what you're working with. Also, you may need to specify how far down the lineage to go with <a href="https://craftcms.com/docs/templating/craft.entries#descendantDist" rel="nofollow noreferrer"><code>.descendantDist()</code></a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-15T00:34:09.443Z
Answers.LastActivityDate: 2017-09-15T00:34:09.443Z
Answers.UserDisplayName: Ryan
Body: <p>I'm trying to load an entry based on the following url:</p>
  
  <pre><code>/artists/nameOfArtist/nameOfCategory/myEntry/thumb
  </code></pre>
  
  <p>This URL follows the structure of my entries: Artist > Category > Entry</p>
  
  <p>So, I'm thinking that something like this should work:</p>
  
  <pre><code>{% set project = craft.request.getSegment(-2) %} 
  </code></pre>
  
  <p>- This gets me the variable from 'myEntry' segment.</p>
  
  <pre><code>{% set artistParent = craft.request.getSegment(-4) %} 
  </code></pre>
  
  <p>- This gets me the variable from 'nameOfArtist' segment.</p>
  
  <p>Then, I want to find the 'project' entry that lives under 'nameOfArtist'.</p>
  
  <pre><code>{% set entry = craft.entries.slug(project).descendantOf(artistParent).first %}
  </code></pre>
  
  <p>but this is not working. What am I missing? Or is there a better way of doing this?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-15T00:14:17.437Z
Comments.Text: I take it the section is a structure (not a channel) called "Artists"? And the category is a `category` and not just another structure entry?
Comments.UserDisplayName: Ryan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-16T03:45:30.060Z
Comments.Text: Both, Artist and Category are structure entries. Category is child of Artist.
Comments.UserDisplayName: SoHo
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-16T06:15:32.363Z
Comments.Text: Ok cool, then does my answer below work for you?
Comments.UserDisplayName: Ryan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-19T13:23:06.760Z
Comments.Text: @Ryan I still need to figure this out. Will post an update.
Comments.UserDisplayName: SoHo
Tags: <routes><descendantof>
Title: Loading entry based on dynamic route
ThreadText: # Loading entry based on dynamic route
  
  (Asked by: username_0 on 2017-09-14)
  
  I'm trying to load an entry based on the following url:
  
  ```
  /artists/nameOfArtist/nameOfCategory/myEntry/thumb
  
  ```
  
  This URL follows the structure of my entries: Artist > Category > Entry
  
  So, I'm thinking that something like this should work:
  
  ```
  {% set project = craft.request.getSegment(-2) %} 
  
  ```
  
  - This gets me the variable from 'myEntry' segment.
  
  ```
  {% set artistParent = craft.request.getSegment(-4) %} 
  
  ```
  
  - This gets me the variable from 'nameOfArtist' segment.
  
  Then, I want to find the 'project' entry that lives under 'nameOfArtist'.
  
  ```
  {% set entry = craft.entries.slug(project).descendantOf(artistParent).first %}
  
  ```
  
  but this is not working. What am I missing? Or is there a better way of doing this?
  
  **Tags:** routes, descendantof
  
  > **Comments:**
  > **username_1**: I take it the section is a structure (not a channel) called "Artists"? And the category is a `category` and not just another structure entry?  
  > **username_0**: Both, Artist and Category are structure entries. Category is child of Artist.  
  > **username_1**: Ok cool, then does my answer below work for you?  
  > **username_0**: @username_1 I still need to figure this out. Will post an update.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-09-15. Score: 1
  
  I think it's because you're trying to cram too much into your `entry` variable. For one, [`.slug()`](https://craftcms.com/docs/templating/craft.entries#slug) is going to return an entry with that slug, so I think that's a bit of a full stop. For two, [`.descendantOf()`](https://craftcms.com/docs/templating/craft.entries#descendantOf) accepts an EntryModal object, but you're feeding it a uri/slug (ie. `name-of-artist`).
  
  Try something like this:
  
  ```
  {% set artistEntry = craft.entries.slug(artistParent).first %}
  {% set projectEntry = craft.entries.descendantOf(artistEntry).first %}
  
  ```
  
  Keep in mind that `.descendantOf()` only works with structures (not channels), so I'm assuming that's what you're working with. Also, you may need to specify how far down the lineage to go with [`.descendantDist()`](https://craftcms.com/docs/templating/craft.entries#descendantDist).
  
  
  ---
  
  