I am using the function.php files wp_enqueue_script function to load in my .js files.
However even though I believe I load jQuery before the slick.js. Slick returns an error in my console 'jQuery is not defined' in slick.min.js. All documents exist and are in the correct location.
function hubble_space_scripts() {
wp_deregister_script('jquery');
wp_enqueue_script('custom-jquery', get_template_directory_uri() . '/js/jquery-3-4-1.js', array(), null, true);
wp_enqueue_script('slick-scripts', get_template_directory_uri() . '/js/slick.js', array(), null, true);
wp_enqueue_script( 'hubble-space-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'hubble-space-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
wp_enqueue_script('pretty-photo-scripts', get_template_directory_uri() . '/js/pretty-photo.js', array(), null, true);
wp_enqueue_script( 'hubble-space-theme-script', get_template_directory_uri() . '/js/hubble-space.min.js', array(), '20151215', true );
wp_enqueue_script('ajax-pagination-scripts', get_template_directory_uri() . '/js/ajax-pagination.js', array(), null, true);
wp_enqueue_script('footer-scripts', get_template_directory_uri() . '/js/footer-scripts.js', array(), null, true);
}
add_action('wp_enqueue_scripts', 'hubble_space_scripts');
Why is this happening? If you could let me know the parts I can copy into my question that are relevant I am happy to provide further resources. Not sure how complex the answer to this question is yet.
Thank you to all contributors, Jason.
I am using the function.php files wp_enqueue_script function to load in my .js files.
However even though I believe I load jQuery before the slick.js. Slick returns an error in my console 'jQuery is not defined' in slick.min.js. All documents exist and are in the correct location.
function hubble_space_scripts() {
wp_deregister_script('jquery');
wp_enqueue_script('custom-jquery', get_template_directory_uri() . '/js/jquery-3-4-1.js', array(), null, true);
wp_enqueue_script('slick-scripts', get_template_directory_uri() . '/js/slick.js', array(), null, true);
wp_enqueue_script( 'hubble-space-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'hubble-space-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
wp_enqueue_script('pretty-photo-scripts', get_template_directory_uri() . '/js/pretty-photo.js', array(), null, true);
wp_enqueue_script( 'hubble-space-theme-script', get_template_directory_uri() . '/js/hubble-space.min.js', array(), '20151215', true );
wp_enqueue_script('ajax-pagination-scripts', get_template_directory_uri() . '/js/ajax-pagination.js', array(), null, true);
wp_enqueue_script('footer-scripts', get_template_directory_uri() . '/js/footer-scripts.js', array(), null, true);
}
add_action('wp_enqueue_scripts', 'hubble_space_scripts');
Why is this happening? If you could let me know the parts I can copy into my question that are relevant I am happy to provide further resources. Not sure how complex the answer to this question is yet.
Thank you to all contributors, Jason.
Share Improve this question asked Jan 31, 2020 at 15:26 Jason Is My NameJason Is My Name 3782 gold badges7 silver badges21 bronze badges 4 |1 Answer
Reset to default 1Long shot, but aren't you by any chance typing $
instead of jQuery
, or vice versa?
(function($) {
// Use $() inside of this function
$('#selector') ...
})(jQuery);
or
// Otherwise use jQuery()
jQuery('#selector') ...
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744786637a4593665.html
custom-jquery
See the $deps argument here developer.wordpress/reference/functions/wp_enqueue_script – Dave Romsey Commented Jan 31, 2020 at 15:33