Register new menu

Hi,

I’m really happy with the sparkling theme so far! However I would like to add a new menu at the top of the header section, above the main menu and logo. I want this to be similar to the footer menu. Just a few links that behave roughly the same way the footer links do.

I’ve managed to create a new menu using register_nav_menus in the functions.php file of my child theme. This menu appears on the dashboard and I am able to assign a menu to it.

I can’t figure out how to get the menu to appear on the front end though. I’ve tried adding it to the header.php file but I can’t figure out how to do it. What other file/files do I need to make changes to?

Sorry if this is a dumb question. This is my first time using wordpress and I’m still a bit confused about where elements are created and called from. And I don’t want to hardcode a new menu in header.php.

Kind regards / Ida

There are three steps you should do to make it work and I will use them as example from the current theme, so you can adopt it.

  1. Register menu
register_nav_menus( array(
		'primary' => __( 'Primary Menu', 'sparkling' ),
		'footer-links' => __( 'Footer Links', 'sparkling' ) // secondary nav in footer
	) );

Above you can see two registered menus. And you can register a new one using the same
register_nav_menus function.

  1. Now you can go ahead and display menu but you can applied the same principle where I have created a function that is later echoed in footer. I did this to make footer.php file as clean as possible

Here you can read more about this function and what it does: http://codex.wordpress.org/Function_Reference/wp_nav_menu


// footer menu (should you choose to use one)
function sparkling_footer_links() {
        // display the WordPress Custom Menu if available
        wp_nav_menu(array(
                'container' => '',                              // remove nav container
                'container_class' => 'footer-links clearfix',   // class of container (should you choose to use it)
                'menu' => __( 'Footer Links', 'sparkling' ),   // nav name
                'menu_class' => 'nav footer-nav clearfix',      // adding custom nav class
                'theme_location' => 'footer-links',             // where it's located in the theme
                'before' => '',                                 // before the menu
                'after' => '',                                  // after the menu
                'link_before' => '',                            // before each link
                'link_after' => '',                             // after each link
                'depth' => 0,                                   // limit the depth of the nav
                'fallback_cb' => 'sparkling_footer_links_fallback'  // fallback function
        ));
} /* end sparkling footer link */
  1. Now cal for this function in footer.php

<?php sparkling_footer_links(); ?>

I believe that you missed second step from this.

Let me know if you need any other help with this one.