WordPress

How To Add A Menu To A WordPress Theme

17th November 2018no commentsStill Life
The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.

Some WordPress themes don’t natively support Menus which was added back in WordPress 3.

To solve this problem you have to add this code to your Theme functions.php file first.

add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array(
'header' => __( 'Header Menu' ),
'footer' => __( 'Footer Menu' )
)
);
}

the next step is to call the menu,

place this code in your header.php file where you want the menu to appear

<?php wp_nav_menu( array( 'theme_location' => 'header' ) ); ?>

and the same goes for the footer menu, place this code in your footer.php file where you want the menu to appear

<?php wp_nav_menu( array( 'theme_location' => 'footer' ) ); ?>

after completing the steps, your theme will support WordPress Menus.



Peter Wootton

Written By: Peter Wootton

Top Ranking SEO Expert & Consultant - Ranked Top On Google For "SEO Manchester". Specialist in Technical SEO.