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 trialJennifer Crawshaw
17,878 PointsNav Menu Not Functioning
Starting a new question because the format was really strange on my last forum post. I cannot get the Nav Menu to work after following the steps to get it working. I have compared my code to the final project, and it is all correct. I have also checked to be sure I have the menu configured right in the admin area. My header.php
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php wp_title(); ?></title>
<?php wp_head(); ?>
</head>
<body>
<header class="row no-max pad main">
<h1><a class='current' href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
<a href="" class="nav-toggle"><span></span>Menu</a>
<nav>
<h1 class="open"><a class='current' href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
<?php
$defaults = array(
'container' => false,
'theme_location' => 'primary-menu',
'menu_class' => 'no-bullet'
);
wp_nav_menu( $defaults );
?>
My functions.php
<?php
add_theme_support( 'menus');
function register_theme_menus() {
register_nav_menus(
array(
'primary-menu' => _('Primary Menu')
)
);
}
add_action( 'init', 'register_theme_menus');
1 Answer
Aaron Eldredge
3,072 PointsI wasn't able to get the nav to function properly until I altered the app.js file to
jQuery(document).ready(function($) {
$(document).foundation();
$( ".nav-toggle" ).click(function() {
$(this).toggleClass("open");
$("nav").fadeToggle(100);
return false; // This is preventing the default action of the .nav-toggle class, which is attached to the anchor.
});
});