###前提・実現したいこと
wordpressで子テーマのfunction.phpで自分で作成したjsを読み込ませたい。
使用している親テーマ:LION MEDIA
http://lionmedia.fit-jp.com/
###発生している問題・エラーメッセージ
wp_enqueue_scriptという関数を使って読み込ませるということはわかったのですが、何故か自分で書いたjsが何も反応してくれません。
GoogleChromeの開発者ツールのconsole上にはエラーメッセージ等は表示されていません。
###子テーマのfunction.phpのコード
<?php ////////////////////////////////////////////////// //親テーマstyle.cssを読み込む ////////////////////////////////////////////////// function fit_head_child() { if ( get_option('fit_seo_cssLoad-main')) { echo '<link class="css-async" rel href="'.get_template_directory_uri().'/style.css">'."\n"; }else{ echo '<link rel="stylesheet" href="'.get_template_directory_uri().'/style.css">'."\n"; } } add_action('wp_head', 'fit_head_child'); ////////////////////////////////////////////////// //下記ユーザーカスタマイズエリア ////////////////////////////////////////////////// //js読み込み function add_scripts() { wp_enqueue_script( 'smart-script', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '20180101', true ); } add_action('wp_print_scripts', 'add_scripts'); ?>
###ディレクトリ構成
lionmedia-child ├ function.php └ js └ custom.js
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/01/03 12:39
2018/01/04 06:26