I am developing a bespoke WordPress Theme for a client and I cannot get the WP Menu to show up on any page (including the Home) and posts!
On the admin backend under apperance > menus it works perfectly!
I am also using the exact same wp_menu array I have used in all of my themes. Here is the code in my header.php file
<div id="menu">
<nav class="top-links" role="navigation">
<?php
wp_nav_menu(array(
'menu' => 'primary',
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'top-links-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
?>
</nav>
</div>
and here is the code in the function.php file…
/* Register the Nav Menu */
function register_my_menus() {
require_once('wp_bootstrap_navwalker.php');
register_nav_menus(array(
'primary' => _( 'Primary Menu' ),
'header-top-menu' => _( 'Header Top Menu' )
));
}
add_action( 'init', 'register_my_menus' );
/* End the Nav Menu */
I am using version 4.1.1 of WordPress and I have cot all my files commented correctly! I know this code does work so have no idea why it’s not on this!
A reduced test case should get you started:
Try changing the
init
action toafter_setup_theme
: