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

Menu not toggling (weird error message)

Hi, I've read all the menu toggling related questions here and tried all the fixes but my menu is still not toggling.

Posting my code here

<?php



  function register_theme_menus() {

    register_nav_menus(
      array(
        'primary-menu' =>__('Primary Menu')
        )
      );
  }
  add_action('init','register_theme_menus');

   function wpt_theme_styles() {

    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_enqueue_style ( 'googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' );
    wp_enqueue_style ( 'main_css', get_template_directory_uri(). '/style.css' );
   }
  add_action('wp_enqueue_scripts', 'wpt_theme_styles');

   function wpt_theme_js() {

    wp_enqueue_script('modernizr_js', get_template_directory_uri(). '/js/modernizr.js', '','',false );
    wp_enqueue_script('foundation_js', get_template_directory_uri(). '/js/foundation.min.js', array('jquery') ,'',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');

  ?>

And this is the error message displaying in the console when i used 'inspect element', "Given URL is not permitted by the Application configuration: One or more of the given URLs is not permitted by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains."

Thanks in advance

Updated the markup around the code in your post slightly so it displayed a little easier to read :)

-Rich

2 Answers

Hi Darrell,

I'm not 100% sure but can you try changing:

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

to:

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

In the dependencies the code above was looking for foundation.js whereas the following line contains foundation_js:

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

-Rich

Thanks so much, that worked. Haven't been able to log on for a few days.

No problem, glad you got it sorted :)

-Rich