• Resolved expromo

    (@expromo)


    Hello everyone!

    I have googled this topic front and backwords and have not found a solution. The problem looks like this.

    I’m working with static-pages only.
    I have a top menu with depth=1 so it displays only the top level of menu.

    I have a menu on the side to display only the further levels so therefore it looks like this :
    $theid = gettheid();
    wp_list_pages(‘child_of=$theid’);

    And I get a list I want but the problem is I only get it when I’m in the top page and when I go into one of the children the menu dissappears – logic.

    I want to menu to stay the same in all further levels of children so I would need something called top_page_id ??

    Any idea on how to do this would be GREAT!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Is this what you are wanting?

    For use in sidebar, display only top level Pages, but when viewing a Page that has children (or is a child) show only children of that parent
    When visiting main page, all top level pages are listed in the sidebar.
    When click on a top level page with no children, all top level pages are listed.
    When click on a top level page with children, just the children pages are listed.
    When click on a children page, just the children of that parent are listed.

    <?php
    $output = wp_list_pages('echo=0&depth=1&title_li=<h2>Top Level Pages </h2>' );
    if (is_page( )) {
      $page = get_query_var('page_id');
      if ($post->post_parent) {
        $page = $post->post_parent;
      }
      $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
      if ($children) {
        $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=<h2>Child Pages</h2>');
      }
    }
    echo $output;
    ?>

    Thread Starter expromo

    (@expromo)

    You went one step too far.
    I just need the page to:
    a) display the children of top parent element on every level
    b) display nothing if there are no children – not display a full menu

    If you could please clarify this for me I would be very greatful.

    EXAMPLE:
    Main page
    |-Subpage 1
    |-Subpage 2

    Generates:

    • Subpage 1
    • Subpage 2
    • When I’m in : Main page, Subpage 1, Subpage 2

      If there are no Subpages the list is empty.

    a) display the children of top parent element on every level

    Don’t use the depth= parameter.

    b) display nothing if there are no children – not display a full menu

    Not sure what you are getting at there.

    Resource:
    wp_list_pages()

    Thread Starter expromo

    (@expromo)

    Thank you for pointing out the resource – can’t believe I missed it.
    The solution I was looking for was: List subpages even if on a subpage

    quick question on same subject, how can you continue showing just those subpages of the main top page (in a sidebar) with a lot of sub levels. I got it working great up to 2 levels deep (see here: https://www.thebestcoffee.com/local/jones-coffee-roasters/biographys/). But if you click on that third level, it turns it into the second level.

    Does that make sense. Click the link above, and click “biographies/Mireya” and you’ll see that it turns “mireya” into the main level.

    Thanks in advance!
    Chuck

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Multilevel page menu static on level2 and more’ is closed to new replies.