1

I'm creating a footer menu and want to show an entry id and its children, atm I'm just getting the descendants but struggling to show the parent and children as well

<nav class="cell small-12">

    <ul class="nested  menu vertical">

        {% set entries = craft.entries.section('pages').descendantOf(8) %}

        <p>{{ entry.parent }}</p>

        {% nav entry in entries %}

        <li><a class="c-main-nav__li__a" href="{{ entry.url }}">{{ entry.title }}</a>

            {% ifchildren %}
            <ul class="menu vertical sub-items">
                {% children %}
            </ul>
            {% endifchildren %}

        </li>

        {% endnav %}

    </ul>

</nav>

Appreciate this is the wrong approach any feedback appreciated on how to display the title of id 8 as well as its children, atm parent.entry is not showing

1

Try merging like this

{% set parent = craft.entries.section('pages').id(8) %}

{% set entries = craft.entries.section('pages').descendantOf(8).limit(1) %}

{% set entries = parent|merge(entries) %}

{% for entry in entries.all() %}
  output your entries here
{% endfor %}
|improve this answer|||||
  • Thanks Sean works a treat! – user2569 Mar 25 '19 at 13:23

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.