WordPress Custom/CMS Menus Tutorial

Lets take a look at how you can use WordPress’ built-in Menu feature to create your own custom menus. WordPress menus allow you to customise and overwrite the default navigation bar that simply displays all CMS pages in alphabetical order. Assuming your theme supports WordPress Menus, you have the ability to:

  • Change the order of your navigation pages
  • Change the labels of your navigation tabs
  • Exclude pages you do not wish to display
  • Include categories, posts and custom links in your navigation
  • Nest pages to create sub-menus

How to register your second menu

Simply locate your functions.php file from within your theme folder, and apply the following code. You can append my reference of ‘Second Menu’ to a term of your choice:

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

The following code demonstrates the registration of both second and third custom menus.


function register_my_menus() {
  register_nav_menus(
    array( 'second-menu' => __( 'Second Menu' ),
    array( 'third-menu' => __( 'Third Menu' )
 )
  );
}
add_action( 'init', 'register_my_menus' );

Deploying your menus

By default, your initial custom menu will simply overwrite your primary navigation. If you’re registering additional menus for your theme then you’ll need to declare within your template where they should appear. To do this, simply use the following code below. In the video, I deploy this code within the footer.php include.

<?php wp_nav_menu( array( 'theme_location' => 'second-menu' ) ); ?>

It’s as simple as that! For more information and options, head over the WordPress developer’s codex for menus.