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 trialSimon Tucker
9,113 Pointsadding jquery js files to my functions.php
I am using slick nav js file in my wordpress theme. I cant seem to get this working as it can't find the correct dir path.
I know it works on my html testing page fine but having real trouble with the functions.php
add_action('wp_enqueue_scripts', 'wpt_theme_styles');
function wpt_theme_js() {
wp_enqueue_script( 'modernizr_js','https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js');
wp_enqueue_script( 'jquery_slicknav', get_template_directory_uri().'/js/jquery.slicknav.min.js', array('jquery'), '', true );
wp_enqueue_script( 'slick', get_template_directory_uri().'/js/slick.nav.js', array('jquery', 'jquery_slicknav'), '', true );
}
add_action('wp_enqueue_script', 'wpt_theme_js');
?>
1 Answer
Tobias Helmrich
31,603 PointsHey Simon,
the action hook is called wp_enqueue_scripts
but you're writing wp_enqueue_script
. Try adding the "s" in the end and see if that works.
I hope that helps! :)
Simon Tucker
9,113 PointsSimon Tucker
9,113 PointsHi there, thanks for the quick response but It's still not working correctly. What is happening is slick nav menus are displaying on full screen but when I resize to mobile view the menu disappears. I know that the css is right so I'm not sure why it's not linking properly in functions.
I even try putting the js scripts in header.php to test and still nothing.
Simon Tucker
9,113 PointsSimon Tucker
9,113 PointsThanks for that Tobias It was not only adding an s but I completely forgot that when a js file is in wordpress it doesn't like $ on it's own, so needed to wrap it in a jquery function like so: