WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP 3 Menus not Showing (5 posts)

  1. Connor Crosby
    Member
    Posted 3 years ago #

    I am making a WordPress theme and I am using the WP menus option. I enabled it in the functions.php file using this code:

    //enable WP 3.0 menus
    add_theme_support( 'menus' );
    if ( function_exists( 'register_nav_menus' ) ) {
    	register_nav_menus(
    		array(
    		  'top_menu' => 'Top Menu',
    		  'bottom_menu' => 'Bottom Menu'
    		)
    	);
    }

    Then I used this code in my header.php and footer.php:

    if(function_exists('register_my_menus')):
    wp_nav_menu(
    array(
    'menu' =>'top_menu',
    'container'=>'',
    'depth' => 1,
    'menu_id' => 'menuTop' )
    );
    endif;

    and

    if(function_exists('register_my_menus')):
    wp_nav_menu(
    array(
    'menu' =>'bottom_menu',
    'container'=>'',
    'depth' => 1,
    'menu_id' => 'menuBottom' )
    );
    endif;

    I cannot figure out why they wouldn't show up at all, I am pretty sure they were showing when I was first configuring it. However, after a day or two when I started working on it again, it doesn't even show up. If for whatever reason it helps, here is my website: http://connorcrosby.net/blog. Thank you!

  2. Connor Crosby
    Member
    Posted 3 years ago #

    I changed it this on the functions.php page:

    register_nav_menus( array(
    'menu_top' => __( 'Top Menu', 'cctheme' ),
    'menu_bottom' => __( 'Bottom Menu', 'cctheme' ),
    ) );

    On the header.php and footer.php (except menu and menu_id are changed) I have:

    wp_nav_menu(
    array(
    'menu' =>'menu_top',
    'container'=>'',
    'depth' => 1,
    'menu_id' => 'menuTop' )
    );

    And it displays my menus however they are the same links. It seems like they are referring to the same menu. When I added a link to my top menu, the bottom menu shows the same thing. And I know they are both set to different ones.

  3. Connor Crosby
    Member
    Posted 3 years ago #

    Never mind, I figured out the problem myself.

  4. greeenkaos
    Member
    Posted 3 years ago #

    care to share? I'm having the same issue with a bottom menu showing the same items as the top menu, though I've done it the same way several times with no problems.

  5. greeenkaos
    Member
    Posted 3 years ago #

    No sure why this is required sometimes and other times not, but it appears the solution is to use the theme_location parameter when calling the menus with wp_nav_menu, such as

    top menu

    <?php wp_nav_menu('menu=top_menu&theme_location=top_menu'); ?>

    bottom menu

    <?php wp_nav_menu('menu=bottom_menu&theme_location=bottom_menu'); ?>

    in my case functions.php looks like

    <?php add_theme_support( 'menus' );
    
    if ( function_exists( 'register_nav_menus' ) ) {
    
    	register_nav_menus(
    
    		array(
    
    		'top_menu' => 'TopMenu',
    
    		'bottom_menu' => 'BottomMenu'
    
    		)
    
    	);
    
    }
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic