WordPress   

Create custom navigation menus in WordPress

Add following code snippet into functions.php file.

Note –  This code snippet will add two custom navigation menus. You can customize it to show more or less number of custom navigation menus  in your WordPress website.

function add_custom_nav_menus() {
	register_nav_menus(
	  array(
		'custom-header-menu' => __( 'Custom Header Menu' ),
		'custom-footer-menu' => __( 'Custom Footer Menu' )
	  )
	);
}
add_action( 'init', 'add_custom_nav_menus' );

Add following code snippet in the template file where the menu will appear in the frontend.

<?php
wp_nav_menu(
	array(
		'theme_location'  => 'custom-header-menu',
		'container_class' => 'header-menu-wrap',
		'menu_class'      => 'header-menu-list',
		'items_wrap'      => '<ul id="header-menu-list" class="%2$s">%3$s</ul>',
		'fallback_cb'     => false,
	)
);
wp_nav_menu(
	array(
		'theme_location'  => 'custom-footer-menu',
		'container_class' => 'footer-menu-wrap',
		'menu_class'      => 'footer-menu-list',
		'items_wrap'      => '<ul id="footer-menu-list" class="%2$s">%3$s</ul>',
		'fallback_cb'     => false,
	)
); 
?>
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us