带有wordpress的jquery循环插件,jquery没有定义?

时间:2012-06-12 13:11:36

标签: jquery wordpress

我对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 &amp; 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未定义”错误。 如何解决此错误并使幻灯片显示正常工作?

1 个答案:

答案 0 :(得分:4)

使用jQuery代替jquery Q必须为大写,inisde slideshow.js