Samuel Stiles
Samuel Stiles

Reputation: 2186

Insert another menu into WordPress... not working at all?

I am following this guide to "Add additional support for menus in your theme":

http://codex.wordpress.org/Navigation_Menus

I followed all of the steps, but this is the result:

http://puu.sh/30bMt.png

So, it's "inserting a menu" where I told it to.... however the items on the menu do not match up with what I have in the WordPress back-end, seen here...

http://puu.sh/30bQd.png

I only inserted 4 items into the menu "Test"... but it's displaying every page, instead of the 4 items I want.

I've attempted to do research to figure out what's going on to no avail; does anybody have any insight as to why this is acting funky?


Code where I'm "registering" the additional menu support... (themes function.php):

function register_my_menus() {
  register_nav_menus(
    array(
      'header-menu' => __( 'Header Menu' )
    )
  );
}
add_action( 'init', 'register_my_menus' );

Code where I'm inserting the "Header Menu" itself... (themes header.php):

<?php
wp_nav_menu( array( 'theme_location' => 'extra-menu', 'container_class' =>'my_extra_menu_class' ) );
?>

Upvotes: 0

Views: 184

Answers (1)

Evicted Cache
Evicted Cache

Reputation: 1401

If you are trying to call 'Header Menu' then the code in your header.php should look like this:

<?php wp_nav_menu(array('theme_location' => 'header-menu', 'menu_class' => 'my_extra_menu_class')); ?>

I'm not sure where you got 'extra-menu' from but WordPress doesn't know what that is since you didn't declare that in your register_my_menus function.

I hope that helps.

Here's an example of how I've implemented multiple menus in my WordPress install:

// Register Extra Menus
function new_register_menus() {
register_nav_menus(array('Products'=>'Products Nav', 'Support'=>'Support Nav', 'Company'=>'Company Nav' , 'Footer'=>'Footer Nav'));
} 
add_action( 'init' , 'new_register_menus' );

//Code in my footer.php
<?php wp_nav_menu(array('theme_location' => 'Footer', 'menu_class' => 'nav')); ?>

Upvotes: 1

Related Questions