Skip to content

Instantly share code, notes, and snippets.

@rahuladams
Created June 12, 2020 12:22
Show Gist options
  • Save rahuladams/355e0e69447c9b0eb2347cc5ce9b2b44 to your computer and use it in GitHub Desktop.
Save rahuladams/355e0e69447c9b0eb2347cc5ce9b2b44 to your computer and use it in GitHub Desktop.
How to register a new menu in dashboard and use it in the theme
//in functions
function register_my_menus() {
register_nav_menus(
array(
'new-menu' => __( 'New Menu' ),
'another-menu' => __( 'Another Menu' ),
'an-extra-menu' => __( 'An Extra Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
//in the theme
wp_nav_menu( array( 'theme_location' => 'new-menu', 'container_class' => 'new_menu_class' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment