WordPress Menu Management

  1. Home
  2. Knowledge Base
  3. WordPress Themes
  4. WordPress Menu Management

One of the best all-around additions to WordPress  is custom Menu management. So how do you implement custom menus into your WordPress site? Simply add a few lines of code in your themes functions.php file, then add the menus where desired in your theme. Yes, it requires adding php code to your themes files, but its simple and easy to understand.

First we register the ability for your theme to use custom menus using the add_theme_support() WordPress function.

Next we define the custom menus. For this example well create two menus: menu-1 and menu-2, and name them Main Navigation and Footer Navigation respectively. We accomplish this in a new function register_site_menus, using the register_nav_menus() WordPress function.

We then initiate the new register_site_menus() function using the add_actions() WordPress function as shown below.

Putting it all together yields the following code to be placed in your themes functions.php file:

Next we add menu-1 our Main Navigation menu, using the wp_nav_menu() WordPress function where we want that menu to appear in your theme (header, sidebar, etc.). We also chose to not have a container automatically added to our menu for this example below.

Well add menu-2 our Footer Navigation menu, using the same function but, we also give the menu a custom CSS id of footer-nav. You can read all about the parameters of the wp_nav_menu() function yourself rather than bore you with the details here.


Was this article helpful?

Related Articles

Leave a Reply