• Resolved Bperth

    (@bperth)


    Hi all,

    I seek to display a menu that will appear the same as when called by get_header call in pages.php, but outside the header.

    I’ve used wp_nav_menu() with no args, which works, but the menu appears without any formatting.

    Is there a way I can make the menu appear the way it appears when called (somewhere) within the get_header call using wp_nav_menu (or any other function call to display the menu)?

    Thanks

    Bruce

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    The formatting is done with your theme’s stylesheet (style.css). Without a link to a page demonstrating the problem, no one will be able to offer much in the way of assistance.

    wp_nav_menu() is fine but you need to wrap it in a div for the styles to be assigned.

    I have a child theme with three menus you may want to download the theme to see how it works.

    It uses get_template_part() to insert the menu, the new menus have their own styles in style.css (custom-styles.css in the download), if you are just moving the menu you would not need your own menu styles.

    Then the menu is in a file called navigation-top.php, and is called like this.

    <?php get_template_part('navigation','top'); ?>

    Inside navigation-top.php we have this line notice the container_id:

    <?php wp_nav_menu( array( 'theme_location' => 'top','container_id' => 'top-menu', 'fallback_cb' => '') ); ?>

    If it was twenty eleven div ‘access’ we could have

    <div id="access">
    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
    </div>

    HTH

    David

    Thread Starter Bperth

    (@bperth)

    Thanks Digital Raindrops,

    I appreciate your prompt reply.

    Do you know where the function get_header is actually located?

    If I could see how this loads the menu I could probably figure out how to do what I want to do.

    Thanks again

    Bruce

    Thread Starter Bperth

    (@bperth)

    Aha!

    This did it.

    <div id=”access”>
    <?php wp_nav_menu ()?>
    </div>

    Wrapping it a div worked, just using the same styles as the normal menu. I can easily modify it by making my own id (based on id – access) in the style sheets.

    Thanks again David 🙂

    Aha!

    This did it.

    Great can you mark this topic resolved please.

    To answer the other question:
    get_header() is a WordPress function that looks in the themes folder for a file called header.php this is where the menu call will be.

    If we wanted a different header file for a page type, lets say in our single post view we wanted to add a new Quote line from a custom field’ section, and remove the header image.

    We would open header php and save it as header-single.php, make our changes in header-single.php

    In single,php we would change get_header() to get_header_(‘single’), and our post single page view would have our new header.

    Likewise get_footer() looks for footer.php

    HTH

    David

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Showing menu outside of get_header’ is closed to new replies.