1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Additional Wordpress Menu

Discussion in 'Content Management' started by CharlyA, Jan 8, 2014.

  1. #1
    Good morning :)

    I ALWAYS struggle with WP Menu's, just can't get my head around them....

    I am working on a theme that only supports one menu so I need to add an additional menu.

    The menu code is:-
    <?php $args = array('container' => 'nav','container_class' => 'sidemenu','walker'=>new ows_walker_nav_menu); ?>
    <?php wp_nav_menu($args); ?>
    PHP:
    Function code is:-
    /* ========================================================================================================================
       
        Register Navigation
       
        ======================================================================================================================== */
    register_nav_menu('main', 'Main navigation menu');
    class ows_walker_nav_menu extends Walker_Nav_Menu {
     
        // add classes to ul sub-menus
        function start_lvl( &$output, $depth ) {
            // depth dependent classes
            $indent = ( $depth > 0  ? str_repeat( "\t", $depth ) : '' ); // code indent
            $display_depth = ( $depth + 1); // because it counts the first submenu as 0
            $classes = array(
                'sub-menu',
                ( $display_depth % 2  ? 'menu-odd' : 'menu-even' ),
                ( $display_depth >=2 ? 'sub-sub-menu' : '' ),
                'menu-depth-' . $display_depth
                );
            $class_names = implode( ' ', $classes );
         
            // build html
            if ($display_depth >= 1) {
                $output .= '<nav class="sub-menu-container">' . "\n";
            }
            $output .= "\n" . $indent . '<ul class="' . $class_names . '">' . "\n";
        }
     
        function end_lvl( &$output, $depth ) {
        // depth dependent classes
        $indent = ( $depth > 0  ? str_repeat( "\t", $depth ) : '' );
        $display_depth = ( $depth + 1); // because it counts the first submenu as 0
        $output .= "\n" . $indent . '</ul>' . "\n";
        if ($display_depth >= 1) {
            $output .= '</nav>' . "\n";
        }
      }
    }
    PHP:
    I have tried changing it myself several times but it either breaks the theme or doesn't do anything. Would really appreciate it if someone could point me in the right direction
     
    CharlyA, Jan 8, 2014 IP
  2. John Michael

    John Michael Member

    Messages:
    154
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    hello its not a big problem here i past some code for you i hope it will help you.
    <?php wp_nav_menu(array('menu'=>'menu','container'=>'','menu_class'=>'menu','id'=>'')); ?>
    Just copy your wordpress menu name and past on the place of "menu".
     
    John Michael, Jan 8, 2014 IP