I am pretty new as WordPress developer and I have the following problem.
I have create the template of this website starting from 0 by myself: http://www.asper-eritrea.com
Now I have add this photo gallery plugin: https://wordpress.org/plugins/robo-gallery/
The problem is that now, when I access to a page that use this plugin, for example: http://www.asper-eritrea.com/photo-gallery/
the gallery is not shown and, into the FireBug console , I obtain this error message:
TypeError: $ is not a function
$(document).ready(function() {
So I think that maybe it could depende by the fact that it can't retrieve JQuery , but I am absolutly not sure about it because I have the same error also opening the others page of my website so I am not sure that the missing of JQuery into the photogallery page is the cause of my problem.
Into the function.php file of my template I have the following function that enqueue all the JavaScript resources (including JQuery), in this way:
/* Hooks a function on to a specific action (an action is a PHP function that is executed at specific
* points throughout the WordPress Core)
* @param 'wp_enqueue_scripts': The name of the action to which 'wpb_adding_styles' is hooked (wp_enqueue_scripts
* is the proper hook to use when enqueuing items that are meant to appear on the front end)
*/
add_action('wp_enqueue_scripts', 'wpb_adding_styles');
/* Function automatically executed by the hook 'load_java_scripts':
* 1) Load all my JavaScripts
*/
function load_java_scripts() {
// Load JQuery:
wp_enqueue_script('jquery');
// Load FlexSlider JavaScript
wp_enqueue_script('flexSlider-js', get_template_directory_uri() . '/assets/plugins/flexslider/jquery.flexslider.js', array('jquery'), 'v2.1', true);
// Load bootstrap.min.js:
wp_enqueue_script('bootstrap.min-js', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap.min.js', array('jquery'), 'v3.0.3', true);
// Load FancyBox:
wp_enqueue_script('fancy-js', get_template_directory_uri() . '/assets/plugins/fancybox/jquery.fancybox.pack.js', array('jquery'), 'v2.1.5', true);
// Load scripts.js:
wp_enqueue_script('myScripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true);
// Load Modernizer:
wp_enqueue_script('myodernizer-js', get_template_directory_uri() . '/assets/js/modernizr.custom.js', array('jquery'), '2.6.2', true);
}
add_action('wp_enqueue_scripts', 'load_java_scripts');
So what is wrong? What am I missing?
The strange thing is that to enqueue JQuery there is:
wp_enqueue_script('jquery');
but there is not specified the exact folder of the Jquery source file (as done for the other resources).
I have JQuery putted into the /assets/bootstrap/js/jquery.js file.
Wordpress generally includes jQuery.noConflict() which removes the $
alias to prevent collisions with other libraries that may also be using $
Change:
$(document).ready(function() {
To
jQuery(document).ready(function($) {
// OK to use `$` here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.