Loading entry based on dynamic route 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?
I think it's because you're trying to cram too much into your entry variable.  For one, .slug() is going to return an entry with that slug, so I think that's a bit of a full stop.  For two, .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().