wordpressでbxsliderと言うjQueryプラグインを動かしたいです。HTMLで作った静的ページではちゃんと動いていたんですが、wordpress上で動かす方法を調べて以下のように作りました。ですが、動かず、どこがダメなのか解明できずテラテイルに質問させてもらっている次第です。よろしくお願いいたします。
現在のbxslider関連の記述は以下の通りです。(動かない)
①header.phpの<head>内に、
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/jquery.bxslider.css"> ```と ```ここに言語を入力 <?php wp_head(); ?> ```を設置。 ②footer.phpに ```ここに言語を入力 <?php wp_footer(); ?> <script type="text/javascript"> jQuery(function($){ jQuery('.slider').bxSlider({ controls:false, auto:true, speed:500, mode:'fade', minSlides: 3 }); }); </script> </body> </html>
③function.phpに
<?php function add_files() { // WordPress提供のjquery.jsを読み込まない wp_deregister_script('jquery'); // jQueryの読み込み wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', "", "201811", false ); // bxsliderのJS wp_enqueue_script( 'bxSlider', get_template_directory_uri() . '/js/jquery.bxslider.min.js', array( 'jquery' ), '201811', true ); } add_action('wp_enqueue_scripts', 'add_files');
以上です。
ご教授いただきたくよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー