3

I want to display the current title of the parent structure inside the child template.

How would I do that?

  • Parent (Title: Bla)
    • Child (Here I want to display Bla)
  • Parent (Title: Blablu)

    • Child (Here I want to display Blablu)

I tried something like (in the child template):

{% set parentTitle = craft.entries.section('structure').level(1).title %}
<h1>{{ parentTitle }}</h1>

But that doesn't even result in an error

KSPR
  • 3,786
  • 2
  • 29
  • 52

1 Answers1

7

If you are trying to get the top most parent entry of a child entry in a structure, you can use ancestorOf.

{% set parent = craft.entries.ancestorOf(entry).level(1).first() %}
<h1>{{parent.title}}</h1
Aaron Berkowitz
  • 3,819
  • 10
  • 20