私はすぐに jQuery UI を必要とする WordPress テーマを構築しています (コアとエフェクトのみで、CSS は含まれていません) (http://hildasjcr.org.uk)。jQuery Effects を使用する必要があり、「$」表記が好きなので、jQuery と jQuery UI の両方の独自のビルドを使用しています。次のように functions.php にスクリプトを含めました。
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', get_template_directory_uri() . "/js/jquery-1.7.2.min.js");
wp_enqueue_script( 'jquery' );
wp_deregister_script( 'jqueryui' );
wp_register_script( 'jqueryui', get_template_directory_uri() . "/js/jquery-ui-1.8.21.custom.min.js");
wp_enqueue_script( 'jqueryui' );
wp_register_script( 'footer', get_template_directory_uri() . "/js/footer.js");
wp_enqueue_script( 'footer' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
これにより、次の HTML コードが得られます (関連するビットに取り除かれます)。
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Current Students</title>
<link rel="stylesheet" type="text/css" media="all" href="http://hildasjcr.org.uk/wp-content/themes/hildas/style.css" />
<script type='text/javascript' src='http://hildasjcr.org.uk/wp-content/themes/hildas/js/jquery-1.7.2.min.js?ver=3.3.2'></script>
<script type='text/javascript' src='http://hildasjcr.org.uk/wp-content/themes/hildas/js/jquery-ui-1.8.21.custom.min.js?ver=3.3.2'></script>
<script type='text/javascript' src='http://hildasjcr.org.uk/wp-content/themes/hildas/js/footer.js?ver=3.3.2'></script>
</head>
残念ながら、jQuery UI は読み込まれているように見えますが、使用できません。jQuery は正常に動作しますが、jQuery UI 関数はすべて未定義です。
Chrome の開発者ツール パネルにリストされている jQuery UI を見て、そこにあるコードを読むことさえできます。
では、何が問題なのか、どうすれば修正できるのでしょうか?