Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRachel Khoong
7,970 PointsWhen in mobile, the nav toggles down but doesn't toggle back up?
Pretty stumped. Tried substituting code from my own mockup and the final project files and it still won't close... help :(
Rachel Khoong
7,970 PointsSorry! Pretty noob with the question-asking here. This is the HTML markup, which is the only thing I changed while doing this.
So it doesn't close when I click the 3-bars again. But it does load the next page closed when I select a menu item...
Sorry if I make little sense :(
<header>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header theNav">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".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>
<a class="navbar-brand" href=" <?php bloginfo( 'url' ); ?>">
<img src="<?php bloginfo('template_directory')?>/img/levelupdicelogo_text.png" alt="Brand" class="hidden-xs"/>
<img src="<?php bloginfo('template_directory')?>/img/levelupdicelogo.png" alt="Brand" class="visible-xs"/>
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse theNav">
<?php
$args = array(
'menu' => 'header-menu',
'menu_class' => 'nav navbar-nav navbar-right',
'container' => 'false'
);
wp_nav_menu($args);
?>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</header>
2 Answers
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsHi Rachel,
Try this in your header.php file like so:
<body <?php body_class(); ?>>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".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>
<a class="navbar-brand" href="<?php bloginfo( 'url' ); ?>"><?php bloginfo( 'name' ); ?></a>
</div>
<div class="navbar-collapse collapse">
<?php
$args = array(
'menu' => 'header-menu',
'menu_class' => 'nav navbar-nav',
'container' => 'false'
);
wp_nav_menu( $args );
?>
</div><!--/.navbar-collapse -->
</div>
</div>
Then include your header.php file in your index.php, home.php, front-page.php, and archive.php files (..not sure if you have already done this or not):
Let me know if you're still stuck:-)
Henrik Hansen
23,176 PointsAlso check what css and js is included. Perhaps you did some css override?
Joe Schultz
6,191 PointsThat helped me out. Thanks!
Rachel Khoong
7,970 PointsThanks everyone for your help! I ended up just redoing it and now it works.. Thanks though!
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsSometimes that's the best way:-)
Henrik Hansen
23,176 PointsHenrik Hansen
23,176 PointsIf you could submit some code that would be helpful. ;)