I'm trying to set up a sub nav from a Structure Section on my site.
Current code is:
{% set mainEntry = craft.entries.slug(craft.request.getSegment(1)).first() %}
{% set subnav = craft.entries.descendantOf(mainEntry).level(2) %}
{{ subnav.total() }}
But my when loop through sub nav below it returns nothing. I am outputting subnav.total above but it is returning 0, but there is a lot of entries in the CMS.
mainEntry gets loaded with the correct info ok, but I don't get anything in subnav.
.level(2)
? Are you not getting descendants at all?