WordPress.org

Ready to get started?Download WordPress

Forums

sub sub sub menu (three levels) (1 post)

  1. ecdq
    Member
    Posted 3 years ago #

    I have this pages menu :

    a
    -aa
    --aaa
    --aab
    --aac
    -ab
    -ac

    On the page aa, I want to show the wp_list_pages aaa, aab & aac, If I'm on the page aaa, I want to show aaa, aab & aac (nothing else). How can I achieve this? For now, I have this code (and it's only working for the second level)

    <?php
    global $wp_query;
    $post = $wp_query->post;
    $ancestors = get_post_ancestors($post);
    if( empty($post->post_parent) ) {
    $parent = $post->ID;
    } else {
    $parent = end($ancestors);
    }
    if(wp_list_pages("title_li=&child_of=$parent&echo=0" )) { ?>

    <div id="secondary-nav" role="navigation" class="menu">

      <?php wp_list_pages("title_li=&child_of=$parent&depth=1" ); ?>

    </div><!-- #secondary-nav -->

    Thanls for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic