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 trial

WordPress WordPress Theme Development Building Out WordPress Navigation The wp_nav_menu Function

Sunho Choi
Sunho Choi
14,817 Points

Menu doesn't toggle after changing foundation.min.js from foundation.js

I've done changing foundation.min.js from foundation.js and even tried using wp_register_style. The menu still doesn't toggle. Console shows no problem. Here is my code for functions.php and app.js

<?php

function wpt_theme_styles() {

    wp_register_style('foundation_css', get_template_directory_uri() . '/css/foundation.css'); 
    wp_enqueue_style('foundation_css', get_template_directory_uri() . '/css/foundation.css'); 

    //wp_enqueue_style('normalize_css', get_template_directory_uri() . '/css/normalize.css');   

    wp_register_style('googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic');
    wp_enqueue_style('googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic');

    wp_register_style('main_css', get_template_directory_uri() . '/style.css');
    wp_enqueue_style('main_css', get_template_directory_uri() . '/style.css');


}
add_action('wp_enqueue_scripts', 'wpt_theme_styles');

function wpt_theme_js(){

    wp_register_style( 'modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false );
    wp_enqueue_script( 'modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false );

    wp_register_style( 'foundation_js', get_template_directory_uri() . '/js/foundation.min.js', array('jquery'), '', true );
    wp_enqueue_script( 'foundation_js', get_template_directory_uri() . '/js/foundation.min.js', array('jquery'), '', true );

    wp_register_style( 'main_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true );
    wp_enqueue_script( 'main_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true );

}
add_action( 'wp_enqueue_scripts', 'wpt_theme_js' );
?>
jQuery(document).ready(function($) {

    $(document).foundation();

    $( ".nav-toggle" ).click(function() {
      e.preventDefault();
      $(this).toggleClass("open");
      $("nav").fadeToggle(100);

      return false;
    });
});

What seems to be the problem? Please help me to get through this.

Jordan Cox
Jordan Cox
8,930 Points

Did you resolve this issue? I'm stuck also and according to digging into the source at the console, it's because of the server failing to load this: <script type='text/javascript' src='http://localhost/localwp.comArray?ver=1'></script>

I also had another issue class.wp-scripts...

2 Answers

Sean May
Sean May
9,145 Points

I was having the same issue, and I think it's mainly because Zac is really missing and not talking about a lot of very small things in this course...

The place where I had a lingering problem was in the last line of the functions.php file, which read (please disregard the opening and closing PHP statements, the code doesn't highlight properly without them)

<?php
add_action('wp_enqueue_script', 'wpt_theme_js');
?>

when it should have read

<?php
add_action('wp_enqueue_scripts', 'wpt_theme_js');
?>

Note the 's' at the end of scripts vs script Just one letter made the entire difference, and I really wish Zac would be more careful about this stuff in these videos, it's leading to a lot of unneeded frustration