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 trialDaniel Horowitz
Courses Plus Student 7,305 PointsCannot get Javascript Menu (top right) to work at smaller screen size.
This is the relevant part of my functions.php. Does this look correct? I have a js folder just within the theme folder. Same level as functions.php
function theme_js() {
global $wp_scripts;
wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', '', '', false );
wp_register_script( 'respond_js', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', '', '', false );
$wp_scripts->add_data( 'html5_shiv', 'conditonal', 'lt IE 9' );
$wp_scripts->add_data( 'respond_js', 'conditonal', 'lt IE 9' );
wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'theme_js' );
4 Answers
Daniel Horowitz
Courses Plus Student 7,305 PointsI found out how to deregister the version of jquery that WP is using and then register the 2.1.1. I checked the page source to ensure that this worked, it did. However, this did not fix the problem!?!?!?!
//Making jQuery Google API
function modify_jquery() {
if (!is_admin()) {
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js', false, '2.1.1');
wp_enqueue_script('jquery');
}
}
add_action('init', 'modify_jquery');
Chung Chin Ang
1,787 PointsHi Daniel,
Just wondering if you manage to solve this issue? I also have the same problem going on.
Cheers.
Zac Gordon
Treehouse Guest TeacherWhen you look at the source code of the site is the proper JS being displayed?
Nijad Kifayeh
6,092 PointsZac, you never mention using the deregister function, however some other netizens seem to say it is needed? What do you think about this...
Daniel Horowitz
Courses Plus Student 7,305 PointsZac, I was having a similar problem in another course I've been working on, until we got this one moving along again. I solved it by ensuring that jquery-2.1.1.min.js was being loaded. The other lesson had a very poor example of using jquery.latest.min.js. Which doesn't load the latest jquery and is bad for a number of reasons, those of which I'm sure you're well aware. How can I change what version of jquery WP is loading?
Daniel