Skip to main content
No need to put Craft 3 in the title, tagging it as [craft3] is better.
Link
Lindsey D
  • 24.1k
  • 5
  • 55
  • 113

In Craft CMS 3, How can I display second level children only from a specific parent structure item?

Source Link
Adam
  • 255
  • 2
  • 7

In Craft CMS 3, How can I display second level children only from a specific parent structure item?

I'm trying to display a list of child structure links, but only from a specific parent. The template I'm working on isn't for the parent in question so I don't think I can use 'entry.'

My structure is set up like this

  • Parent 1
  • --Child One
  • --Child Two
  • --Child Three
  • Parent 2
  • --Child One
  • --Child Two

I only want to display the children of Parent 1. What I have so far is

<ul id="sub-menu"> {% set pages = craft.entries.section('visit').level('>1') %} {% nav entry in pages %} <li><a href="{{ entry.url }}">{{ entry.title }}</a> {% ifchildren %} <ul> {% children %} </ul> {% endifchildren %} </li> {% endnav %} </ul> 

Using this outputs all of the second level children instead of just the children from Parent 1. Is there any way to specify that the only children I want to display must come from Parent 1? Can I specify a slug somehow?

Any help much appreciated