moving menu from header to sidebar (4 posts)

  1. dijxtra
    Posted 4 years ago #

    Hi there everybody,

    I'm wp n00b, but I'm fluent in PHP. I'd like to move my nav-menu from header to the sidebar.

    The template I use (raindrops) generates horizontal menu in the header with this:
    wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary'));

    In the sidebar I already have a list of pages generated with this:
    wp_list_pages('title_li=<h2 class="h2">'. __( 'Pages', 'Raindrops').'</h2>' );

    I like the way that wp_list_pages renders everything, and I'd like to get the same result as wp_list_pages, but instead of list pages to get my primary navigation menu.

    How do I do that?

    Thanks in advance!

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    You will need to move the call to wp_nav_menu() to sidebar.php to replace wp_list_pages. Depending upon how the theme's CSS works, you may also have to make some changes to the stylesheet and/or the register_nav_menus() function in functions.php

  3. dijxtra
    Posted 4 years ago #

    Well, yes. The point is that simply moving wp_nav_menu() gives me horizontal menu wrapped in several lines instead of vertical menu. So, yes, I could just write my own CSS from scratch for this particular menu.

    But I figured that I should be able to somehow tell wp_nav_menu() to use the same CSS that wp_list_pages() uses. Is that possible? Is there a way to make a function wp_list_only_pages_which_are_in_primary_menu() which produces the same results as wp_list_pages()?

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    I doubt you're going to be able to completely replicate the CSS for wp_list_pages via the wp_nav_menu parameters.

Topic Closed

This topic has been closed to new replies.

About this Topic