jQuery(…)。nivoSlider不是WordPress中的一个函数

我在我的网站上使用wordpress。 在使用主题的开头,滑块正在工作,但现在我收到这些错误

TypeError:jQuery(…)。nivoSlider不是一个函数

TypeError:jQuery(…)。lightbox不是一个函数

TypeError:jQuery(…)。prettyPhoto不是一个函数

TypeError:$不是函数

我的网站地址是: http://www.rgesc.com/ ://www.rgesc.com/我一直在寻找这个问题的解决方案一周,我试图在nivo.slider.js上面添加jquery libs并试图输入这个。 我对wordpress并不擅长,在这个问题上需要帮助。

 var j = jQuery.noConflict(); 

但没有变化。

       

这在头标记之间排列

   jQuery(window).load(function() { // nivoslider init jQuery('#slider').nivoSlider({ effect: 'boxRainReverse', slices:15, boxCols:8, boxRows:8, animSpeed:500, pauseTime:5000, directionNav:false, directionNavHide:false, controlNav:true, captionOpacity:1 }); });  

这行低于其他脚本

  

额外的照片厨房也不起作用。 我刚认识到这一点。

下面是使用Docs示例的WordPress实现示例 ,正确排队样式和脚本,并将所有演示文件放在目录/wp-content/themes/your-theme/nivo/

在此处输入图像描述

以下代码插入functions.php主题文件中。 短代码是显示滑块的辅助工具, [test-nivo] (您必须从post中提取图像才能使其动态化)。 注意使用捆绑的WP jQuery作为我们脚本的依赖项,尽量不要使用任何外部jQuery,因为它们没有启用noConflict模式。
主要WPfunction: get_stylesheet_directory_uriwp_enqueue_scriptwp_enqueue_scripts
在此处查看捆绑的WP脚本的完整列表。

 add_shortcode( 'test-nivo', 'shortcode_so_22436214'); add_action( 'wp_enqueue_scripts', 'enqueue_so_22436214' ); /** * SHORTCODE output */ function shortcode_so_22436214( $atts ) { $nivo_folder = get_stylesheet_directory_uri() . '/nivo'; $output = <<      
This is an example of a HTML caption with a link.
HTML; return $output; } /** * ACTION Enqueue scripts */ function enqueue_so_22436214() { wp_register_script( 'nivo-pack', get_stylesheet_directory_uri() . '/nivo/jquery.nivo.slider.pack.js' ); wp_enqueue_script( 'nivo-start', get_stylesheet_directory_uri() . '/nivo/start-nivo.js', array( 'jquery', 'nivo-pack' ), false, true ); wp_enqueue_style( 'nivo-css', get_stylesheet_directory_uri() . '/nivo/nivo-slider.css' ); }

我们的自定义JS文件, start-nivo.js

 jQuery( document ).ready( function( $ ) { $('#slider').nivoSlider({ effect: 'random', // Specify sets like: 'fold,fade,sliceDown' slices: 15, // For slice animations boxCols: 8, // For box animations boxRows: 4, // For box animations animSpeed: 500, // Slide transition speed pauseTime: 3000, // How long each slide will show startSlide: 0, // Set starting Slide (0 index) directionNav: true, // Next & Prev navigation controlNav: true, // 1,2,3... navigation controlNavThumbs: false, // Use thumbnails for Control Nav pauseOnHover: true, // Stop animation while hovering manualAdvance: false, // Force manual transitions prevText: 'Prev', // Prev directionNav text nextText: 'Next', // Next directionNav text randomStart: false, // Start on a random slide beforeChange: function(){}, // Triggers before a slide transition afterChange: function(){}, // Triggers after a slide transition slideshowEnd: function(){}, // Triggers after all slides have been shown lastSlide: function(){}, // Triggers when last slide is shown afterLoad: function(){} // Triggers when slider has loaded }); }); 

你包括jQuery三次:

  1. 的jquery.js?版本= 1.8
  2. jQuery的1.10.2.min.js
  3. jQuery的1.7.1.min.js

在第一个将删除绑定到$和jQuery的所有插件之后的include,包括jQuery一次,你将解决问题。

除非绝对必要,否则我建议只使用1个jQuery版本。

以下是如何使用jQuery.noConflict()在网站上使用多个jQuery版本