List child pages of parent?

This is my loop:

<div class="band"><Loop type=page parent=31416 include_children=true order=asc orderby=title>
    <div class="item"><a href="{Field url}" class="card"><If field image exists><div class="thumb" style="background-image: url({Field image_url});"></div></If>
  <h4><Field title /></h4>
  <p><Field excerpt auto=true /></p>

I’d like to generalize this to a template that can pick up the ID from the current page and use it with the parent operator. Is there a variable for that?

So if I understand correctly you just want to pass the current page ID to the “parent” query parameter?

<Loop type=page parent="{Field id}" include_children=true order=asc orderby=title>...</Loop>

You can pass fields to parameters by using quotation marks and curly braces! Because we’re getting the ID as we define the loop it inherits the context of default query, which would be the current page if placed on a page :slight_smile:

@benjamin wrote a really great article explaining how to use the Loop tag which includes a good overview of query context and passing data between loops :slight_smile:


Of course it was staring me right in the face!

Thank you :slight_smile:

1 Like