• Resolved lberelson

    (@lberelson)


    Hopefully easy question. I would like to ‘reuse’ my global navigation which uses the wp_nav_menu code:

    <div id="menusimple">
    <?php wp_nav_menu( array( 'theme_location'=>'primary-menu',  'container'=>'menusimple', 'container_class'=>'menu',  )); ?>
    </div>

    Rather than repeating this code in multiple templates, is there a built in tag such as get_header or get_sidebar to call it up?
    Something along these lines: http://codex.wordpress.org/Stepping_Into_Template_Tags

Viewing 1 replies (of 1 total)
  • Thread Starter lberelson

    (@lberelson)

    Well in case anyone sees this… I think I found the answer here:’http://codex.wordpress.org/Function_Reference/get_template_part

    this seems to work. Parsing the code properly may mean dividing the divs differently between the code snippet and the template… but here’s what i have and it works.

    Be sure to use a hyphen for file name…
    Menu snippet in this file: menu-primary.php
    template calls the menu like this:
    <?php get_template_part( ‘menu’, ‘primary’ ); // Loads the menu-primary.php template. ?>

    Makes more sense in a longer more complicated menu code than what I’m currently using.

Viewing 1 replies (of 1 total)
  • The topic ‘Get Menu – Reuisng menu code’ is closed to new replies.