Skip to main content

Create a custom navigation menu

You can register menu locations with register_nav_menus, or declare them in a YAML file of a config/ directory. Simply registers them on the init action.

config/nav-menu/menus.yaml
nav_menu:
header: Header menu
footer: trans(Footer, mydomain)

Each key is a menu location, each value its description. trans(text, domain) is replaced by __().

caution

Spaces are removed from the values before trans() is read: trans(Footer menu, mydomain) becomes __('Footermenu', 'mydomain'). Use trans() only for texts without spaces, or register the menus in PHP.