How to Add Custom Secondary Navigation Menu in WordPress?
Would you like to add secondary top menu in your WordPress Theme? Here we are going to assist you with this article to add custom navigation menus. Some WordPress Themes are generous and easily allow selecting and creating navigation menus. By Default many themes comes with pre defined secondary menus option for layout & locations. Below on this page we show you how to add more nav menus in your theme.
First of all you have to be sure that your theme doesn’t have feature to add navigation menus in the top. You can use plugin “Header and Footer”. It has got very good reviews by users because of its functionality. So give it a try to add your custom menus. For this navigate to Plugins and click on Add Plugins. Search for this plugin as Head, Footer and Post Injections. Install & Activate it. Inside the settings area there is a widget as header and footer.
You can go in your post or page area if you wanted. Before moving further make sure you have a backup of current version of your website. In the plugin you have to add the nerd code after the body tag so use that area.
Instead of this you can also use a simple way for creating custom navigation menus in WordPress. Navigation Menus are by default exclusive feature of WordPress CMS. Each theme has its own menu style & location that it support.
To add a custom menu in the nav bar first you need to register it by adding the below given code in your themes functions.php file.
function wpb_custom_new_menu() {
register_nav_menu(‘my-custom-menu’,__( ‘My Custom Menu’ ));
}
add_action( ‘init’, ‘wpb_custom_new_menu’ );
Now go to Appearance and then menu page in the admin area of your WordPress site to create or edit a menu. Below on the theme page you will see a option as “My Custom Menu” as theme location option. If you would like to add more custom menus you have to use the below given code.
function wpb_custom_new_menu() {
register_nav_menus(
array(
‘my-custom-menu’ => __( ‘My Custom Menu’ ),
‘extra-menu’ => __( ‘Extra Menu’ )
)
);
}
add_action( ‘init’, ‘wpb_custom_new_menu’ );
Once you add more menus in the menu location, Go to menu items in the WordPress Dashboard.
After creating the menus we also need to display it to the right place. The most common section where the menu is place is header section of the website.
However you can ad custom menus anywhere you want. You have to add this given code in the WordPress Theme template where you want to display your menu.
<?php
wp_nav_menu( array(
‘theme_location’ => ‘my-custom-menu’,
‘container_class’ => ‘custom-menu-class’ ) );
?>
Container class is the CSS Class that will add to your menus. Your menus will shown as a bulleted list. You have to use .custom_menu_class to give a style to your menus.