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

6

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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