WordPress.org

Support

Support » How-To and Troubleshooting » sub sub sub menu (three levels)

sub sub sub menu (three levels)

  • 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!

  • The topic ‘sub sub sub menu (three levels)’ is closed to new replies.