WordPress.org

Ready to get started?Download WordPress

Forums

3 level deep menu - showing menu on the parent page (2 posts)

  1. vikkineal
    Member
    Posted 1 year ago #

    Here is my menu structure...

    1. Aftersales (main menu item)
    2. Aftersales
    2. Parts
    3. Parts form 1
    3. Parts form 2
    3. Parts form 3
    2. Service

    My code creates a three level menu structure which outputs my child pages If the user is in 2 /3.

    The trouble is, I want the menu structure to also show IF the user is on the top most parent page (1) - in this case the Aftersales landing page. At the moment when you land on it, there's no subnavigation and you have to go back up to the dropdown to select, Aftersales, Parts or service.

    How can I add it to the code below?

    Thanks in advance

    `<?php
    echo "<h3 id=\"categoryTitle\"><span>-</span> ";
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    echo " <span>-</span></h3>";

    $subPage = is_subpage();
    $ancestor = $post->ancestors[1];
    if ($subPage) : // we're on a sub-page:
    if ($ancestor) : // we're a sub-sub nav item...
    echo "<ul id=\"secondaryNavigation\">";
    wp_list_pages("title_li=&child_of=$ancestor&sort_column=menu_order&exclude=147");
    echo "</ul>";
    else :
    echo "<ul id=\"secondaryNavigation\">";
    wp_list_pages("title_li=&child_of=$subPage&sort_column=menu_order&exclude=147");
    echo "</ul>";
    endif;
    endif;

    ?>`

  2. vikkineal
    Member
    Posted 1 year ago #

    anybody?

Topic Closed

This topic has been closed to new replies.

About this Topic