I am creating my 2nd custom WordPress theme and having problems.
I used the same method in my 1st theme and it worked fine, but not this time of course.
I registered my menu in functions.php like this:
<?php
//Register main menu
function register_theme_menu() {
register_nav_menu( 'primary', 'Main Navigation Menu' );
}
add_action( 'init', 'register_theme_menu' );
?>
And called the menu in my header.php like this:
<!-- Menu -->
<nav class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
<div class="navbar-header">
<button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<nav class="navbar-collapse bs-navbar-collapse collapse" role="navigation">
<ul class="nav navbar-nav">
<?php wp_nav_menu( array(
'theme_location' => 'main-menu',
'menu_class' => 'nav navbar-nav'
) ); ?>
</ul>
</nav>
<!-- End menu -->
I set mu menu in WP backend but its not responding, it just lists all my pages on the front end. Where am I going wrong?
Thanks