OK、これは私の functions.php ファイルにあります: (以下は、以下のクールな回答を利用するために編集されたバージョンです。後でオリジナルを残します:
function mdg_setup_scripts() {
wp_register_script( 'hoverIntent', get_bloginfo('template_url').'/js-custom/hoverIntent.js', array( 'jquery' ));
wp_enqueue_script( 'hoverIntent' );
wp_register_script( 'mdMenuAnimation', get_bloginfo('template_url').'/js-custom/mdMenuAnimation.js', array( 'jquery' ));
wp_enqueue_script( 'mdMenuAnimation' );
}
add_action( 'wp_enqueue_scripts', 'mdg_setup_scripts' );
これが私がもともと持っていたものです:
function mdg_setup_scripts() {
wp_register_script( 'hoverIntent',
get_bloginfo( 'template_url' ) . '/js/hoverIntent.js',
array( 'jquery' ),
false,
true );
wp_register_script( 'mdMenuAnimation',
get_bloginfo('template_url') . '/js/mdMenuAnimation.js',
array( 'jquery', 'hoverIntent' ),
false,
false );
if (!is_admin()) {
wp_enqueue_script( 'mdMenuAnimation' );
}
}
add_action( 'init', 'mdg_setup_scripts' );
js ファイルは、指定されたフォルダーにあります。しかし、JavaScript はまったくフロントエンドにロードされていません。私は何か間違ったことをしていますが、何ですか?jqueryを登録する必要がありますか(ただし、WPにはjqueryが含まれていると思いました)?エンキュー呼び出しを分離する必要がありますか? header.php に何か追加する必要がありますか?