If you need to get the level 2 children for a specific Structureparent entry, and you have that entry's EntryModelentry model instance (i.e. you have an entry
variable which refers, referring to the Structureparent entry), you can just use the EntryModel'sthat entry model's children
property (which returns a pre-baked entry query, appendingfetching that entry's child entries only). Add the level
level
parameter to only pullfetch children fromat the desired level:
{% set children = entry.children().level(2).all() %}
There'sFor "standalone" entry queries, there's also athe descendantOf
parameter which can be used in a craft.entries
query – obviously, this. This should be set to the Structureparent entry's ID (or the complete EntryModelyou can also pass an entry model, ie.eg. entry
):
{% set entries = craft.entries({
'section' : 'yourSectionHandle',
'level' : 2,
'descendantOf' : entry.id
}) %}
{% set entries = craft.entries
.section('yourSectionHandle')
.descendantOf(entry.id)
.level(2)
.all()
%}
Also, ifIf you want to pullfetch entries from a structure section at a certain level in a Structure section, but not limit itlimited to children of a certainany particular parent entry, you can append the level
parameter to your basic craft.entries
queryentry query:
{% set entries = craft.entries.section('yourSectionHandle').level(2) %}
{% for entry in entries %}
...
{% endfor %}
{% set entries = craft.entries.section('yourSectionHandle').level(2).all() %}
Note that craft.entrieslevel
queries can alsoparameter doesn't necessarily have to be typed out using object notation,an integer; if you prefer (I find the object notation more readablewant to fetch entries at any level at or above 2, especially if you havecan pass a lot of parameters)string prefixed with the >=
operator:
{% set entries = craft.entries({
'section' : 'yourSectionHandle',
'level' : 2
}) %}
{% set entries = craft.entries.section('yourSectionHandle').level('>= 2').all() %}
Check out the official docs for the entry query level
parameter for more examples.