<p><a href="http://buildwithcraft.com/docs/templating/craft.entries#descendantOf" rel="nofollow">descendantOf</a> accepts either an EntryModel object or an entry’s ID. And you are passing it a string that isn't the id, so that's why it isn't working</p>

CC BY-SA 3.0
2014-07-21T16:10:10.413Z
2014-07-21T16:10:10.413Z
Marion Newlevant
<p>There may be a better option, but off the top of my head, you could do:</p>

<pre><code>{% set countParent = craft.entries.slug('oakview-hotel').first() %}
{% set count = craft.entries.section('hotelDetails').descendantOf(countParent).level(3).type('review').total() %}
        {{ count }}
</code></pre>

CC BY-SA 3.0
2014-07-21T13:46:45.500Z
2014-07-21T13:46:45.500Z
Steve Abraham
<p>I'm using this in the root of a structure to try and get the count of entries in another part of the structure.</p>

<pre><code>{% set count = craft.entries.section('hotelDetails').descendantOf('oakview-hotel').level(3).type('review').total() %}
        {{ count }}
</code></pre>

<p>But it's including entries from other hotels, I hoped descendantOf('oakview-hotel') would restrict the count to only oakview-hotel. When I replace escendantOf('oakview-hotel') with descendantOf(17) 17 being the ID oakview-hotel the count is restricted to oakview-hotel and the entry count is correct.</p>

<p>Ca anyone please telly me why descendantOf('oakview-hotel') isn't working for me or suggest a better way to do this?</p>

<structure>
How can I get the count of entries in a structure?
# How can I get the count of entries in a structure?

(Asked by: username_0 on 2014-07-21)

I'm using this in the root of a structure to try and get the count of entries in another part of the structure.
{% set count = craft.entries.section('hotelDetails').descendantOf('oakview-hotel').level(3).type('review').total() %}
        {{ count }}

But it's including entries from other hotels, I hoped descendantOf('oakview-hotel') would restrict the count to only oakview-hotel. When I replace escendantOf('oakview-hotel') with descendantOf(17) 17 being the ID oakview-hotel the count is restricted to oakview-hotel and the entry count is correct.
Ca anyone please telly me why descendantOf('oakview-hotel') isn't working for me or suggest a better way to do this?

**Tags:** structure


---

## 2 answers

### Answer by username_2 on 2014-07-21. Score: 11 | Accepted answer

There may be a better option, but off the top of my head, you could do:
{% set countParent = craft.entries.slug('oakview-hotel').first() %}
{% set count = craft.entries.section('hotelDetails').descendantOf(countParent).level(3).type('review').total() %}
        {{ count }}


---

### Answer by username_1 on 2014-07-21. Score: 2

[descendantOf](http://buildwithcraft.com/docs/templating/craft.entries#descendantOf) accepts either an EntryModel object or an entry’s ID. And you are passing it a string that isn't the id, so that's why it isn't working


---

