Hello Developers,
Here you can find quick code for creating a custom navigation menu.
For creating a custom navigation menu, the first thing you need to do is add your new navigation menu by putting below code to your theme’s functions.php file.
function wpb_custom_nav_menu() { register_nav_menus( array( 'my-nav-menu' => __( 'My Nav Menu' ), ) ); } add_action( 'init', 'wpb_custom_nav_menu' );
Now go to Appearance » Menus page in your admin and create a new menu. You will see ‘’My Nav Menu’ as theme location option.
Output will be there as below:
If you want to add more than one new navigation menu location, then you would need to use a code like below:
function wpb_custom_again_menu() { register_nav_menus( array( 'my-nav-menu' => __( 'My Nav Menu' ), 'second-nav-menu' => __( 'My second Nav Menu' ) ) ); } add_action( 'init', 'wpb_custom_again_menu' );
Output will be there as below:
Thank you 🙂