WordPress Nav Menu Functions

Index
About This Index
This page is the WordPress Nav Menu Functions index. Each row links to a full guide with syntax, three examples, and FAQs.
Learn the big picture on WordPress Nav Menus. Use this page when you need one function, such as wp_nav_menu() or walk_nav_menu_tree().
Remember.
You build a menu in Appearance > Menus, and you show it with wp_nav_menu(). walk_nav_menu_tree() is a helper behind the scenes, and you only call it for custom menu HTML.
Syntax
How to Call a Nav Menu Function
Register a location once, then show it in your theme.
WordPress
<?php
// functions.php: register the location.
register_nav_menus( array( 'primary' => 'Primary Menu' ) );
// header.php: show the menu assigned to it.
wp_nav_menu( array( 'theme_location' => 'primary' ) ); Browse
WordPress Nav Menu Functions Table
All function guides in this WordPress nav menu series (2 tutorials). Start with wp_nav_menu().
Frequently Asked Questions
They are functions that show a navigation menu in your theme and build the HTML for its items.
Use wp_nav_menu(). Register a location with register_nav_menus(), assign a menu in Appearance > Menus, and then call wp_nav_menu() with theme_location.
Rarely. wp_nav_menu() calls it for you. Use it only when you build custom menu HTML from menu item objects, often with a custom walker.
It is a named place in your theme, such as primary or footer, where an admin can assign a menu.
No menu is assigned to the location, so wp_nav_menu() runs its fallback, wp_page_menu. Set fallback_cb to false to show nothing.
Start with wp_nav_menu(). Learn walk_nav_menu_tree() later, when you need a custom walker.
Start with wp_nav_menu()
Display a menu in your theme, with simple options.
8 people found this page helpful
