Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Add menus to a WordPress Theme

In functions.php, register menus:

function theme_setup() {
    register_nav_menus( array(
		'main_menu' => esc_html__( 'Main Menu', 'theme' ),
	) );
add_action( 'after_setup_theme', 'theme_setup' );

In theme file:

wp_nav_menu( array( 
    'theme_location' => 'main_menu',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment