WordPress calls these Navigation Menus. There are a few steps:
-
Set up a child theme, if you aren’t already using one. That way your changes won’t be lost when the main theme is updated.
-
Register the menu – in your child theme’s
functions.php
file,
function mythemeslug_register_custom_menu() {
register_nav_menu('topnav', __('Top Nav'));
}
add_action('init', 'mythemeslug_register_custom_menu');
- Call the menu in the theme – you’ll most likely want this in your child theme’s
header.php
file.
wp_nav_menu(array('menu' => 'topnav'));
There are various ways to call it but in this example you’re calling the menu with the name ‘topnav’. You can alternatively designate a ‘theme location’ and call it that way. You can also control the HTML container and CSS classes, among other things. Follow the links above to learn more about various options.
- Build the menu in wp-admin – you can do this in either the Customizer or under Appearance > Menus.
If you need to heavily customize the HTML markup, you can create a custom walker.