• Hey Folks!

    I’ve been using wp_list_pages to display the current page’s childpages in the sidebar.
    It works great for pages that only have other pages as a child, but for our new project i need a different solution.

    Our main navigation mostly consists of pages, but there’re also post categories and custom post type items.
    Let’s say there’s a parent page called “about”, it’s child pages are three normal pages and one post category, all assembled in the theme’s menu settings page.

    If i’m using wp_list_pages now, i only get the three child pages of the parent, not the category.
    I need a way to read the active wp_nav_menu parent and display it’s child items, whether pages or categories.

    I have no clue if this is possible, help would be much appreciated.
    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I found your post while searching for the same exact requirements. I wondered if there was a way to show the wp_nav_menu children of the current page. Seems like it’d be difficult to do but I’m still searching. I have a menu where it is common to have categories instead of pages so the wp_list_pages shows nothing in my child menu of course.

    Thread Starter pixelschupser-nw

    (@pixelschupser-nw)

    Hey inhouse,

    did you find a solution to our problem?

    Still havent’s found anything personally.
    Any ideas of how this could be accomplished?

    Hi pixelschupser-nw, I ended up just using a second instance of the wp_nav_menu in my page template and then hiding the top level pages via CSS. Hide the “container-class ul li” with display:none and then for “container-class ul ul li” use display:block. That or use the current-menu-item class and the sub-menu. I pasted some CSS below. Let me know if you need more help.

    wp_nav_menu( array( 'container_class' => 'child-menu', 'theme_location' => 'main-menu' ) );
    .child-menu ul li {display:none;}
    .current-menu-item ul li {display:block;} (or inline-block depending on your design)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_nav_menu children subnavigation on page’ is closed to new replies.