• Resolved xmatter

    (@xmatter)


    I have 2 sidebars (left and right)

    <?php
    
    if ( function_exists('register_sidebar') ) {
        register_sidebar(array(
    	'name'=>'Left',
            'before_widget' => '<div class="widget">',
            'after_widget' => '</div>',
            'before_title' => '<h4>',
            'after_title' => '</h4>',
        ));
    	register_sidebar(array(
    	'name'=>'Right',
            'before_widget' => '<div class="widget">',
            'after_widget' => '</div>',
            'before_title' => '<h4>',
            'after_title' => '</h4>',
        ));
    }

    I want a menu registered for each sidebar but something is incorrect. I am not sure what to place for sidebar2. Sidebar2 works for displaying the menu within the backend, but the left menu appears on the frontend in both the left and right sidebars.

    function register_my_menus() {
      register_nav_menus(
        array( 'header' => __( 'Header' ), 'main' => __( 'Main' ), 'sidebar' => __( 'Left Sidebar' ), 'sidebar2' => __( 'Right Sidebar' ), 'footer' => __( 'Footer' ))
      );
    }

    Here is the code to display menus with the sidebar-left and sidebar-right is identical

    <?php wp_nav_menu(array( 'container_class' => 'sidebar-left', 'theme_location' => 'sidebar')); ?>

    so whatever gets changed within the menu register array, i must change within the sidebar-right file to display the proper menu. Any help is appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The problem appears to be that you are using the same code to display both left and right sidebars:

    Here is the code to display menus with the sidebar-left and sidebar-right is identical

    The theme_location parameter points to the unique menu to be displayed, so it should be sidebar2 to display the ‘Right Sidebar’.

    Thread Starter xmatter

    (@xmatter)

    thank you, I did eventually figure it out. I wasn’t sure if it was sidebar2 specifically or not.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Menu Registration In Functions’ is closed to new replies.