In looking at the the BaseElementModel:getDescendants() method and saw it checks for eager loading elements named 'descendants.'

// Eager-loaded?
if ($this->hasEagerLoadedElements('descendants'))
    return $this->getEagerLoadedElements('descendants');

I added with and the descendants condition to a Structure and the page is now loading with a few less queries.

{% set entries = craft.entries({
    section: 'sectionHandle',
    limit: null,
    with: [
}) %}

Can anybody explain what is happening here?

1 Answer 1


Craft 2.6.2789 added this feature, which is seems you've reverse engineered. :)

It is now possible to eager-load Structure entries' and categories' descendants using the 'descendants' handle.

  • Easy points! And I see I should have searched the changelog, not the docs ;-) Commented Jun 29, 2016 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.