Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-21T16:10:10.413Z
Answers.LastActivityDate: 2014-07-21T16:10:10.413Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-21T13:46:45.500Z
Answers.LastActivityDate: 2014-07-21T13:46:45.500Z
Answers.UserDisplayName: Steve Abraham
Body: <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>
  
Tags: <structure>
Title: How can I get the count of entries in a structure?
ThreadText: # 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
  
  
  ---
  
  