Wordpress - Themes and Appearance
You want to create two menu locations in your theme: one for the header and one for the footer. Which code correctly registers both menus and displays them in the theme?
register_nav_menus() with an array of locations inside a function hooked to after_setup_theme.wp_nav_menu() with theme_location keys matching registered locations.function register_my_menus() {
register_nav_menus(array(
'header' => 'Header Menu',
'footer' => 'Footer Menu'
));
}
add_action('after_setup_theme', 'register_my_menus');
// In header.php
wp_nav_menu(array('theme_location' => 'header'));
// In footer.php
wp_nav_menu(array('theme_location' => 'footer')); correctly hooks registration to after_setup_theme, uses register_nav_menus(), and displays menus properly.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions