• Hi everyone!
    i’ve been trying for hours and googled it, but i still cant figure out how to do this. I can outout everything, but just cant get the logic right. Any help is MUCH appriciated. Here we go:
    I have one Main menu that outputs top lvl pages.

    I want one menu below that outputs the children of whatever top lvl page i am one (only one lvl of childs. Not the third lvl)

    And when i am on a child page. I want the children of that page to be listed on a sidebar..

    So. to recap. Level 1 as main menu. Show children of current page. And when on a child, show children to that child in a sidebar.
    |Level1 Level1 Level1|
    |ChildofClickedlvl1 ChildofClickedlvl1 |
    (sidebar)
    | ChildrenofChild |
    | ChildrenofChild |

    How do i do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • https://codex.www.ads-software.com/Function_Reference/wp_list_pages#List_Sub-Pages

    The biggest problem you will have is correctly identifying the current page id in the various templates.

    Thread Starter bjornhall

    (@bjornhall)

    Yes, that is correct. But how do i do it? Got to be more people who have this issue. But all i can find is older forums posts with soloutions that uses plugins thats no longer supported.

    I have gotten as far as i can list the child of a parent, and then on the child, list its children. But when i click the grandchild. The child of the parent (top level) displays the grandchild instead of the child of the parent (top level).

    Could you be more specific, I have a couple of functions for categories that I am working on, you would have to adjust for pages these highlight all levels, check out the menu here:

    I can post some code tonight to pastebin.

    Or is it just a missing class in your style.css, do you have class styles for ancestors?

    menu (ancestor)
    — Sub Menu (parent)
    —Sub Sub Menu (current)

    menu (ancestor)
    — Sub Menu (ancestor)
    —Sub Sub Menu (ancestor)
    —- Sub Sub Sub Menu (parent)
    —– Sub Sub Sub Sub Menu (current)

    HTH

    David

    Thread Starter bjornhall

    (@bjornhall)

    I could try! I can post a link, since its for a client. But i uploaded a “drawing” explaining!
    https://awesomescreenshot.com/0aaegm181

    My problem is that. i can get it to list the third level. But when i enter that third level page, i second level starts to display the third level aswell.

    Right now i got a temp fix for it, a nasty one, including plugin and hiding elements. And the query to get the third level is ugly. Here it is:

    <?php
    $gen1 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 0  AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen1_ids = implode($gen1,', ');
    $gen2 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen1_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen2_ids = implode($gen2,', ');
    $gen3 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen2_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen3_ids = implode($gen3,', ');
    wp_list_pages('include=' . $gen3_ids . '&title_li=');
    ?>

    and using the “simple nav” plugin to display the second lvl. and hiding the the parts i dont want:
    simple_section_nav('before_widget=<li>&after_widget=</li>&show_on_home=0&title= ');

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Three-level menu. On different locations?’ is closed to new replies.