This is a very simple technique to adding a another menu to your WordPress theme. Simply take this snippet and add it to your theme’s functions.php file. If your theme is using a menu already you’ll want to add this near that snippet. I’ll also show you how to call an array. For now let’s focus on adding a second menu.
function serafin_menus() { $locations = array(
'secondary' => __( 'Secondary', 'twentytwenty' ),
);
register_nav_menus( $locations );
}
add_action( 'init', 'serafin_menus' );
Once you’ve added the snippet above head on over to Appearances > Menus and you’ll see the new secondary menu added.
Now create a new menu and call it whatever you want and then check the box “Secondary”
Once you’re done all that you’re going to want to add the code below to call the new menu somewhere on your theme. Place it wherever you want. In your header or footer or wherever you plan on adding it. One thing to note here is that in most cases you’re going to want to create a child theme when you are planning on customizing your theme. Especially if your theme is a premium paid for theme.
<nav>
<?php
wp_nav_menu(
array('container_class' => 'menu-secondary',
'theme_location' => 'secondary') );
?>
</nav>
That’s basically it. From here you’ll be good to go with a adding menus in wordpress. Any questions comment below and I’ll be more than happy to help. Thanks for visiting my site.
