Support » Plugins » Hacks » custom menus

  • Hi,

    Looking for a bit of advice. I’m looking to create a menu stucture in columns, up to five…something functioning like the nav system on:

    so clicking a top level in column one shows it’s children in column two, clicking a child in column two shows it’s children in column 3.

    have been reading the codex page on wp_list_pages( $args ); but just can’t seem to get my head around it.

    Any suggestions or guidance most welcome!

    Thanks in advance

Viewing 1 replies (of 1 total)
  • Each one of those menus must be created with a separate call to wp_list_pages. It’s easy enough to create a child menu using the ‘child_of’ and ‘depth’ parameters. The tricky part is generating the menu hierarchy. One way to do this is to climb the page ladder from the current page up to the top level, building an array of page IDs as you go, and then loop through that array in reverse order to generate the menus.

    The following code should do the trick. This is meant to be used outside the loop — in the header, or at the very top of the page template.

    // Get the page ladder for the current page
    global $wp_query;
    $my_page = get_page($wp_query->get_queried_object_id());
    $page_ladder = array($my_page->ID);
    while ( $my_page->post_parent ) {
        $my_page = get_page($my_page->post_parent);
        $page_ladder[] = $my_page->ID;
    // Top level menu
    // Child menus (if any)
    $page_ladder = array_reverse($page_ladder);
    foreach( $page_ladder as &$my_page ) {
        wp_list_pages('title_li=' . get_the_title( prev($page_ladder) ) . '&depth=1&child_of='.$my_page);
Viewing 1 replies (of 1 total)
  • The topic ‘custom menus’ is closed to new replies.