我对wordpress很新,我很困惑。我正在尝试创建一个幻灯片放映并遵循我可以找到的所有指示,以便将jquery添加到wordpress
在我的function.php
文件中,我添加了:
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
在header.php
我有:
<?php
wp_enqueue_script('jquery.cycle.js', get_bloginfo("stylesheet_directory").'/js/jquery.cycle.js', array('jquery'));
wp_enqueue_script('slideshow', get_bloginfo("stylesheet_directory") . '/js/slideshow.js');
wp_head();
?>
我的slideshow.js
是:
jquery(document).ready(function($){
jquery('#gallery').cycle('fade');
});
在我的模板中我有:
<div id="gallery">
<p>
<a href="http://bdf.serverplanet.com/wp-content/uploads/2012/06/BD_Laurene1339467077747.jpg">
<img src="http://bdf.serverplanet.com/wp-content/uploads/2012/06/BD_Lauren_s.jpg" alt="Caption" />
</a>
<em>Brad & Lauren</em>
</p>
<p>
<a href="http://bdf.serverplanet.com/wp-content/uploads/2012/06/BD_bike.jpg" target="_blank">
<img src="http://bdf.serverplanet.com/wp-content/uploads/2012/06/BD_bike_s.jpg" alt="Caption" />
</a>
<em>Biking on the Vineyard</em>
</p>
<a href="http://bdf.serverplanet.com/wp-content/uploads/2012/06/bedcad.jpg" target="_blank"><img src="http://bdf.serverplanet.com/wp-content/uploads/2012/06/bedcad_s.jpg" alt="Caption" /></a>
<em>Brad and Cass</em>
<a href="http://bdf.serverplanet.com/wp-content/uploads/2012/06/brad11.jpg" target="_blank">
<img src="http://bdf.serverplanet.com/wp-content/uploads/2012/06/brad11_s.jpg" alt="Caption" />
</a>
<em>At the S.A.S.S. show</em>
<a href="http://bdf.serverplanet.com/wp-content/uploads/2012/06/Brad_and_Alexis.jpg" target="_blank">
<img src="http://bdf.serverplanet.com/wp-content/uploads/2012/06/Brad_and_Alexis_s.jpg" alt="Caption" />
</a>
<em>With Alexis at a S.A.S.S. show</em>
</div>
当我尝试运行幻灯片时,我的slideshow.js
文件中出现“jquery未定义”错误。
如何解决此错误并使幻灯片显示正常工作?
答案 0 :(得分:4)
使用jQuery
代替jquery
Q
必须为大写,inisde slideshow.js